Naudingos komandos Linux sistemoms

Pateikiame pamoką, kurioje rasite sąrašą bash skriptų, kurie padės lengviau atlikti kasdienius administravimo veiksmus Linux sistemų administratoriui. Šios komandos leidžia kasdieninias užduotis atlikti greičiau be pasikartojančių komandų vedimo.

Užduotis, kurias galite atlikti naudojant šiuos skriptus:

Norint patogiai matyti auksčiau pateiktą informaciją, turite įsidiegti bash skriptą. Visų pirmą jį atsisiųskite:

wget https://raw.githubusercontent.com/sathisharthar/Admin-Scripts/master/sysinop

Paleiskite skriptą:

bash sysinop

arba:

sh sysinop

Tada Jums bus pateikiamas meniu:

Fri Mar  6 13:52:56 EET 2020--------------------------- Main Menu---------------------------1. Operating system info
2. Hostname and dns info
3. Network info
4. Who is online
5. Last logged in users
6. Free and used memory info
7. Get my ip address
8. My Disk Usage
9. Process Usage
10. Users Operations
11. File Operations
12. ExitEnter your choice [ 1 -12 ]   

1. Operacinės sistemos informacija:

Įvedus 1 Jums bus pateikiama sistemos informacija, kaip pavyzdžiui:

---------------------------------------------------------------
  System information 
---------------------------------------------------------------
Operating system : Linux
LSB Version:    :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID:    CentOS
Description:    CentOS Linux release 7.7.1908 (Core)
Release:    7.7.1908
Codename:    Core
Press [Enter] key to continue...

2. Hostname ir DNS informacija

Pateikiama DNS ir kita su IP susijusi informacija:

---------------------------------------------------------------
  Hostname and DNS information 
---------------------------------------------------------------
Hostname : con2
DNS domain : x-x-x.pro
Fully qualified domain name : con2.x-x-x.pro
Network address (IP) : x.x.x.x
DNS name servers (DNS IP) : x.x.x.x
x.x.x.x
Press [Enter] key to continue...

3. Tinklo informacija

Pateikiama visa NIC informacija bei viešų ir privačių IP adresų informacija:

---------------------------------------------------------------
  Network information 
---------------------------------------------------------------
Total network interfaces found : 3
*** IP Addresses Information ***
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    inet 127.0.0.1/8 scope host lo
2: venet0: <BROADCAST,POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN 
    inet 127.0.0.1/32 scope host venet0
    inet x.x.x.x/32 brd x.x.x.x scope global venet0:0
    inet x.x.x.x/8 brd x.x.x.x scope global venet0:1
***********************
*** Network routing ***
***********************
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
x.x.0.0     0.0.0.0         255.255.0.0     U         0 0          0 venet0
x.0.0.0        0.0.0.0         255.0.0.0       U         0 0          0 venet0
0.0.0.0         0.0.0.0         0.0.0.0         U         0 0          0 venet0
**************************************
*** Interface traffic information ***
**************************************
Kernel Interface table
Iface             MTU    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
lo              65536        0      0      0 0             0      0      0      0 LRU
venet0           1500   181111      0      0 0        124054      0      0      0 BOPRU
venet0:0         1500      - no statistics available -                        BOPRU
venet0:1         1500      - no statistics available -                        BOPRU

4. Prisijungusių naudotojų informacija

Pateikiama visų tuo metu prisijungusių prie serverio naudotojų sąrašą:

---------------------------------------------------------------
  Who is online 
---------------------------------------------------------------
NAME     LINE         TIME         COMMENT
root     pts/0        Mar  6 08:48   (x-x-x)admin    :0           Mar  6 12:28   (x-x-x)

5. Paskutiniai prisijungę naudotojai

Pateikia paskutinių prisijungusių naudotojų istorija:

---------------------------------------------------------------
  List of last logged in users 
---------------------------------------------------------------
root     pts/0        x.x.x    Fri Mar  6 08:48   still logged in
root     :0           x.x.x    Fri Mar  6 12:28   still logged in   
reboot   system boot  2.6.32-042stab14 Fri Mar  6 08:45 - 14:17  (05:32)    

wtmp begins Fri Mar  6 08:45:24 2020

6. Laisvos ir panaudotos atminties informacija

Pateikiama visa informacija apie atmintį, kuri naudojama serverio ir laisvos bei naudojamos atminties kiekius:

---------------------------------------------------------------
  Free and used memory 
---------------------------------------------------------------
              total        used        free      shared  buff/cache   available
Mem:          16384          22       15476           0         884       16278
Swap:             0           0           0
*********************************
*** Virtual memory statistics ***
*********************************
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0      0 15848084      0 905864    0    0     0    17    0    4  0  0 100  0  0
***********************************
*** Top 5 memory eating process ***
***********************************
sshd      2263  0.1  0.0      0     0 ?        Z    14:24   0:00      \_ [sshd] <defunct>
rpc       1232  0.0  0.0  69228  1308 ?        Ss   10:45   0:00 /sbin/rpcbind -w
root      2270  0.0  0.0   4324   548 pts/0    S+   14:24   0:00  |           \_ head -5
root      2269  0.0  0.0  18980   780 pts/0    S+   14:24   0:00  |           \_ sort -nr -k 4
root      2268  0.0  0.0  51700  1696 pts/0    R+   14:24   0:00  |           \_ ps auxf

7. Serverio IP adreso pateikimas

---------------------------------------------------------------
  Public IP information 
---------------------------------------------------------------
212.24.110.243

8. Disko atminties informacija

Pateikia procentinę dalį visos išnaudotos atminties kiekiui:

---------------------------------------------------------------
  Disk Usage Info
---------------------------------------------------------------
1% /

9. Naudojami procesai

Pateikiamas meniu paprastesnei procesų peržiūrai:

1. Pateikiami visi veikiantys procesai:

root         1     0  0 08:45 ?        00:00:01 /usr/lib/systemd/systemd --system --deserialize 26
root         2     1  0 08:45 ?        00:00:00 [kthreadd/4642]
root         3     2  0 08:45 ?        00:00:00 [khelper/4642]
root       105     1  0 08:45 ?        00:00:01 /usr/lib/systemd/systemd-journald
root       132     1  0 08:45 ?        00:00:00 /usr/lib/systemd/systemd-logind
dbus       137     1  0 08:45 ?        00:00:01 /usr/bin/dbus-daemon--system--address=systemd: --nofork --nopidfile --systemd-activation
root       683     1  0 08:46 ?        00:00:00 /usr/lib/systemd/systemd-udevd
root       838     1  0 08:46 ?        00:00:00 /usr/sbin/sshd -D
root       942     1  0 08:46 ?        00:00:00 /usr/sbin/crond -n
root      1034     1  0 08:46 tty2     00:00:00 /sbin/agetty --noclear tty2 linux
root      1035     1  0 08:46 tty1     00:00:00 /sbin/agetty --noclear --keep-baud console 115200,38400,9600 vt220
root      1042   838  0 08:48 ?        00:00:00 sshd: root@pts/0
root      1044  1042  0 08:48 pts/0    00:00:00 -bash
root      1138     1  0 09:05 ?        00:00:01 /usr/sbin/httpd -DFOREGROUND
apache    1139  1138  0 09:05 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache    1140  1138  0 09:05 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache    1141  1138  0 09:05 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND

2. Proceso nutraukimas

Suteikia galimybę nutraukti procesą pagal jo ID numerį:

Please enter the PID of the process you would like to kill:3214

3. TOP komandos pateikimas

Atidaromi top komandos rezultatai:

4. Grįžimas į pagrindinį meniu.

5. Shut down - serverio išjungimas.

10. Naudotojų veiksmai

Jums bus pateikiamas papildomas meniu su pasirinkimais:

1. Naudotojo sukūrimas:

Turite įvesti naudotojo vardą, grupę ir pilną vardą:

           Please enter the new username below:  (NO SPACES OR SPECIAL CHARACTERS!)

test

           Please enter a group for the new user:  (STILL NO SPACES OR SPECIAL CHARACTERS!)

test

           What is the new user's full name?  (YOU CAN USE SPACES HERE IF YOU WANT!)

testas


                     New user test created successfully.

                     (press ENTER to continue)

2. Grupės pakeitimas naudotojui:


           Which user needs to be in a different group? (USER MUST EXIST!)

test

           What should be the new group for this user?  (NO SPACES OR SPECIAL CHARACTERS!)

testas1


                     User test added to group testas1 successfully.

                     (press ENTER to continue)

3. Grupės sukūrimas:

           Please enter a name for the new group below:  (NO SPACES OR SPECIAL CHARACTERS!)

testass


                     Group testass created successfully.

                     (press ENTER to continue)

4. Naudotojo pašalinimas:

           Please enter the username to be deleted below:  (THIS CANNOT BE UNDONE!)

test

           ARE YOU ABSOLUTELY SURE YOU WANT TO DELETE THIS USER? SERIOUSLY, THIS CANNOT BE UNDONE! y/n
y


                     User test deleted successfully.

                     (press ENTER to continue)                  (press ENTER to continue)

5. Pakeisti slaptažodį:


           Which user's password should be changed?
testinis

Changing password for user testinis.
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.
                     Password for testinis changed successfully.

                     (press ENTER to continue)

6. Grįžti į pagrindinį meniu.

7. Shut down - išjungti serverį.

11. Veiksmai su failais

Suvedus atitinkamą skaičių bus atliekami tam tikri veiksmai su failais. Visi veiksmai atliekami tokiu pačiu principu, kaip ir ir 9tame ir 10 pagrindinio meniu punkte.