Warning: session_start(): open(/var/cpanel/php/sessions/alt-php74/sess_ae9b126af2015435721e3b8f953039e8, O_RDWR) failed: No such file or directory (2) in /home/xsofthost/public_html/help/wp-content/plugins/accelerated-mobile-pages/includes/redirect.php on line 358

Warning: session_start(): Failed to read session data: files (path: /var/cpanel/php/sessions/alt-php74) in /home/xsofthost/public_html/help/wp-content/plugins/accelerated-mobile-pages/includes/redirect.php on line 358
Frequently Common Linux Commands for Administrators - XsoftHost

Frequently Common Linux Commands for Administrators

Useful Common Linux Commands for System Administrators

This article help System Administrators to learn common useful and frequently used Linux or Unix commands some commands are critical and we should be aware and understand the commands carefully before run it on your VPS or dedicated servers.

  1. Uptime Command :uptime command shows since how long your system is up and running ,also show the number of users are currently logged in in the system and displays load average for 1,5 and 15 minutes intervals.

    uptime
    15:19:25 up 12 days, 22:50, 1 user, load average: 0.02, 0.12, 0.19
  2. W Command : W displays information about the users currently on the Server , and show user’s processes. The header shows, in this order, the current time,how long the system has been running, how many users are currently logged on, and the system load averages for the past 1, 5, and 15 minutes .The command has the following options:

    • -f : Remove From “Looged IP” from displays.
    • -s : Remove JCPU and PCPU from displays.
    • -h : displays no header entries.
    • -V : (upper letter) – Shows versions.

    w
    USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
    root pts/0 127.0.0.1 15:19 5.00s 0.08s 0.00s w
  3. Users Command :displays the current logged in users.

    users
    root
  4. Who Command :who command is similar to w command. Unlike w command who doesn’t print how user’s processes.

    The command has the following options:

    • -a, –all : Displays all information in cumulatively.
    • -r : Shows current runlet.
    • -b : Displays last system reboot date time.

    who
    root pts/0 2016-12-13 15:19 (127.0.2.1)
  5. Whoami Command :display the current user, as example if you are logged as root the result will be root.

    whoami
    root
  6. ls Command :ls command display list of files in human readable format for the current location. You can use ls -ltr to display the result with sort files by last modified time.

    ls -l
    total 28
    drwx–x–x 6 root root 4096 Dec 13 02:00 BackupDataFolder
    -rw-r–r– 1 root root 236 Nov 27 19:12 install.log
    drwxr-xr-x 2 root root 4096 Dec 12 21:57 tempfolder
  7. Crontab Command :The crontab is a list of commands that you want to run on a regular schedule, and also the name of the command used to manage that list. The crontab -l will display list of cron schedule jobs

    crontab -e: This will open the crontab in a text editor

    crontab -l
    00 * 20 * * /bin/local >/job.php
    15 * * * * /bin/jobs >/job1.php
  8. More Command :more command allows quickly view file and shows details in percentage. You can page up and down. By Pressing ‘q’ letter you can quit from more window command.

    more installapp.log
    Installing filesystem-1.6.4.i86
    Installing xml-curl-1.3.4.i64
    Installing iso-codes-3.16-2.el6.noarch
    –More–(20%)
  9. Less Command :more command allows quickly view file . You can page up and down. By Pressing ‘q’ letter you can quit from less window command.

    less installapp.log
    Installing filesystem-1.6.4.i86
    Installing xml-curl-1.3.4.i64
    Installing iso-codes-3.16-2.el6.noarch
  10. Copy Command :Copy file from source to destination . Or you can use the command cp -i sourcefile destinationfile To prompt before overwrite file.

    cp -p sourcefile destinationfile
  11. Print Working Directory Command : Show the current directory for the current logged user session.

    pwd
    /var/Backup
  12. VI Command : for editing the file after showing the file contents Press “i” to start edit the file and press ESC to end edit and then type :wq to write the update .

    vi /etc/config.txt
  13. SSH Command : SSH command is used to login into remote host server by passing IP address with username .

    To check the version of ssh use option -V (uppercase).

    ssh root@[Remote IP]
  14. Ftp/sftp Command : To connect to remote server using FTP protocol or sftp to remote secure FTP protocol .

    To check the version of ssh use option -V (uppercase).

    To ignore the SSL certificate use set ssl:verify-certificate no after you logged to remote ftp server

    ftp [Remote IP]
    sftp [Remote IP]
  15. Service Command : The service command allow you to start stop and restart the Linux services .

    service httpd start — Start httpd service
    service httpd stop — Stop httpd service
    service httpd restart — Restart httpd service
    service httpd status — Show httpd service Status The Next is example result:
    httpd.service – Apache web server managed by cPanel EasyApache
  16. Memory Command : free command show free, total and swap ,available memory information in bytes .

    free
    total used free shared buff/cache available
    Mem: 60229664 901560 512044 1338828 58816060 57705696
    Swap: 0 0 0
  17. Top Command : displays processor activity of your system and also displays tasks managed by kernel in real-time. To quite the window press “q”

    top
    top – 19:29:20 up 13 days, 2:59, 1 user, load average: 0.02, 0.04, 0.05
    Tasks: 53 total, 1 running, 152 sleeping, 0 stopped, 0 zombie
    %Cpu(s): 0.0 us, 0.2 sy, 0.0 ni, 99.8 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
    KiB Mem : 60229664 total, 501920 free, 903428 used, 58824316 buff/cache
    KiB Swap: 0 total, 0 free, 0 used. 57695652 avail Mem
    PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
    8491 root 20 0 155796 2192 1528 R 0.7 0.0 0:00.03 top
  18. Extract Zipped file Command : the following show how to Extract “.zip”,”.tar”,”tar.gz”,”.rar”

    unzip archive.zip — Extract .zip file
    tar -xvf archive.tar — Extract .tar file
    tar -zxvf archive.tar.gz — Extract .tar.gz file
    rar x archive.rar — Extract .rar file
    tar -zcf archive-name.tar.gz foldername/ — Extract .tar.gz file to foldername
  19. Grep Search Command : grep command search string in all files in the current folder ,or search keyword in a file contents

    grep -ir searchkeyword * — Search searchkeyword in all files inside the current folder
    grep -r searchkeyword /var/www/vhosts/file.logs — Search searchkeyword in file.logs
  20. lsof Command : display the currnet of all opened files , you can specify the opened files by user

    lsof — display all opened files
    lsof -u root — display all opened files by user root
  21. last Command : display user’s activity in the system

    last — For all Users
    root pts/1 127.0.0.1 Tue Dec 13 19:44 still logged in
    root pts/0 127.0.0.1 Tue Dec 13 15:19 still logged in
    jone pts/0 127.0.0.1 Mon Dec 12 22:36 – 01:48 (03:11)
    root pts/0 127.0.0.1 Thu Dec 1 10:27 – 01:48 (07:11)
    last root — For root User
    root pts/1 127.0.0.1 Tue Dec 13 19:44 still logged in
    root pts/0 127.0.0.1 Tue Dec 13 15:19 still logged in
    root pts/0 127.0.0.1 Thu Dec 1 10:27 – 01:48 (07:11)
  22. Remove File Command : Command with options to remove or delete files

    rm file-name — delete a file without prompting for confirmation
    rm -i tetfilename.txt — delete a file with prompting for confirmation
    rm: remove regular file ‘tetfilename.txt’?
  23. Folders Command : Commands to make new directory or remove directory

    mkdir newdirectory — create new newdirectory directory on the current folder
    rm -rf “directory name” — remove the “directory name” and its sub folders and files
  24. Disk Space Command : Determine how much disk space You have in Linux and Unix

    df -h — dispaly Linux Disk Space Information
    Filesystem Size Used Avail Use% Mounted on
    /dev/sda1 1500G 320G 1468G 2% /
    /dev/sdb1 1500G 520G 980G 35% /mount1
    /dev/sdc1 1500G 1000G 500G 66% /mount2
    tmpfs 100G 0 100G 0% /run/sub/10
Share on facebook
Share on twitter
Share on linkedin
Share on telegram
Share on whatsapp

Related Posts