30 Useful Linux Commands For System Administrators
30 Useful Linux Commands For System Administrators
1. Uptime Command
In Linux uptime command shows since how long your system
is running and the number of users are currently logged in and
also displays load average for 1,5 and 15 minutes intervals.
#uptime
08:16:26up22min,1user,loadaverage:0.00,0
.03,0.22
Manager
Linux Bible Packed with Updates and Exercises
A Newbies Getting Started Guide to Linux
Linux from Scratch Create Your Own Linux OS
Linux Shell Scripting Cookbook, Second Edition
[tecmint@tecmint~]$uptimeV
procpsversion3.2.8
2. W Command
It will displays users currently logged in and their process
along-with shows load averages. also shows the login name,
tty name, remote host, login time, idle time, JCPU, PCPU,
command and processes.
#w
08:27:44up34min,1user,loadaverage:0.00,0
.00,0.08
USERTTYFROMLOGIN@IDLE
JCPUPCPUWHAT
tecmintpts/0192.168.50.107:590.00s
0.29s0.09sw
Available options
3. Users Command
Users command displays currently logged in users. This
command dont have other parameters other than help and
version.
#users
tecmint
4. Who Command
who command simply return user name, date, time and host
information. who command is similar to w command. Unlike w
command who doesnt print what users are doing. Lets
illustrate and see the different between who and w commands.
#who
tecmintpts/02012091807:59(192.168.50.
1)
#w
08:43:58up50min,1user,loadaverage:0.64,0
.18,0.06
USERTTYFROMLOGIN@IDLE
JCPUPCPUWHAT
tecmintpts/0192.168.50.107:590.00s
0.43s0.10sw
5. Whoami Command
whoami command print the name of current user. You can also
use who am i command to display the current user. If you are
logged in as a root using sudo command whoami command
return root as current user. Use who am i command if you
want to know the exact user logged in.
#whoami
tecmint
6. ls Command
ls command display list of files in human readable format.
#lsl
total114
drxrxrx.2rootroot4096Sep1808:46bin
drxrxrx.5rootroot1024Sep815:49boot
#lsltr
total40
rwrr.1rootroot6546Sep1718:42install.
log.syslog
rwrr.1rootroot22435Sep1718:45install.
log
rw.1rootroot1003Sep1718:45anaconda
ks.cfg
7. Crontab Command
List schedule jobs for current user with crontab command and
-l option.
#crontabl
0010***/bin/ls>/ls.txt
Edit your crontab with -e option. In the below example will open
schedule jobs in VI editor. Make a necessary changes and quit
pressing :wq keys which saves the setting automatically.
#crontabe
8. Less Command
less command allows quickly view file. You can page up and
down. Press q to quit from less window.
#lessinstall.log
Installingsetup2.8.1410.el6.noarch
warning:setup2.8.1410.el6.noarch:HeaderV3RSA/
SHA256Signature,keyIDc105b9de:NOKEY
Installingfilesystem2.4.302.1.el6.i686
Installingcacertificates2010.633.el6.noarch
Installingxmlcommon0.6.332.el6.noarch
Installingtzdata2010l1.el6.noarch
Installingisocodes3.162.el6.noarch
9. More Command
more command allows quickly view file and shows details in
percentage. You can page up and down. Press q to quit out
from more window.
#moreinstall.log
Installingsetup2.8.1410.el6.noarch
warning:setup2.8.1410.el6.noarch:HeaderV3RSA/
SHA256Signature,keyIDc105b9de:NOKEY
Installingfilesystem2.4.302.1.el6.i686
Installingcacertificates2010.633.el6.noarch
Installingxmlcommon0.6.332.el6.noarch
Installingtzdata2010l1.el6.noarch
Installingisocodes3.162.el6.noarch
More(10%)
10. CP Command
Copy file from source to destination preserving same mode.
#cppfileAfileB
#cpifileAfileB
11. MV Command
Rename fileA to fileB. -i options prompt before overwrite. Ask
for confirmation if exist already.
#mvifileAfileB
#catfileAfileB
#catinstall.log|less
#catinstall.log|more
#cd/fileA
#pwd
/root
#sortfileA.txt
#sortrfileA.txt
16. VI Command
Vi is a most popular text editor available most of the UNIX-like
OS. Below examples open file in read only with -R option. Press
:q to quit from vi window.
#viR/etc/shadows
#sshV
OpenSSH_5.3p1,OpenSSL1.0.0fips29Mar2010
#ftp192.168.50.2
#sftp192.168.50.2
#ftp>mput*.txt
#ftp>mget*.txt
#servicehttpdstart
OR
#/etc/init.d/httpdstart
#free
totalusedfreeshared
bufferscached
Mem:10308007359442948560
51648547696
/+buffers/cache:136600894200
Swap:206437602064376
#freet
totalusedfreeshared
bufferscached
Mem:10308007360962947040
51720547704
/+buffers/cache:136672894128
Swap:206437602064376
Total:30951767360962359080
#toputecmint
top11:13:11up3:19,2users,loadaverage:0
.00,0.00,0.00
Tasks:116total,1running,115sleeping,0st
opped,0zombie
Cpu(s):0.0%us,0.3%sy,0.0%ni,99.7%id,0.0%wa
,0.0%hi,0.0%si,0.0%st
Mem:1030800ktotal,736188kused,294612kfr
ee,51760kbuffers
Swap:2064376ktotal,0kused,2064376kfr
ee,547704kcached
PIDUSERPRNIVIRTRESSHRS%CPU%MEM
TIME+COMMAND
1889tecmint200114681648920S0.00.2
0:00.59sshd
1890tecmint200512416681416S0.00.2
0:00.44bash
6698tecmint200116001668924S0.00.2
0:01.19sshd
6699tecmint200512415961352S0.00.2
0:00.11bash
#tarcvfarchivename.tar/home
Download Now
#tarxvfarchivename.tar
#greptecmint/etc/passwd
tecmint:x:500:500::/home/tecmint:/bin/bash
JoinOver95000+LinuxUsers
SHARE
57,739
114
3,201
25,639
1.2k
149
#find/nametecmint
/var/spool/mail/tecmint
/home/tecmint
/root/home/tecmint
38
58
#lsofutecmint
COMMANDPIDUSERFDTYPEDEVICESIZE/OF
FNODENAME
sshd1889tecmintcwdDIR253,0409
62/
sshd1889tecminttxtREG253,053233
COMMENTS
Subscribe
6298069/usr/sbin/sshd
sshd1889tecmintDELREG253,0
412940/lib/libcom_err.so.2.1
sshd1889tecmintDELREG253,0
393156/lib/ld2.12.so
sshd1889tecmintDELREG253,0
298643/usr/lib/libcrypto.so.1.0.0
sshd1889tecmintDELREG253,0
393173/lib/libnsl2.12.so
sshd1889tecmintDELREG253,0
412937/lib/libkrb5support.so.0.1
sshd1889tecmintDELREG253,0
412961/lib/libplc4.so
#last
tecmintpts/1192.168.50.1TueSep180
8:50stillloggedin
tecmintpts/0192.168.50.1TueSep180
7:59stillloggedin
rebootsystemboot2.6.32279.el6.iTueSep180
7:5411:38(03:43)
rootpts/1192.168.50.1SunSep161
0:40down(03:53)
rootpts/0:0.0SunSep161
0:3613:09(02:32)
roottty1:0SunSep161
0:07down(04:26)
rebootsystemboot2.6.32279.el6.iSunSep160
9:5714:33(04:35)
naradpts/2192.168.50.1ThuSep130
8:07down(01:15)
You can use last with username to know for specific users
activity as shown below.
#lasttecmint
tecmintpts/1192.168.50.1TueSep180
8:50stillloggedin
tecmintpts/0192.168.50.1TueSep180
7:59stillloggedin
tecmintpts/1192.168.50.1ThuSep130
8:07down(01:15)
tecmintpts/4192.168.50.1WedSep121
0:1212:29(02:17)
27. ps command
#psef|grepinit
root10007:53?00:00:04/sb
in/init
root75086825011:48pts/100:00:00gre
pinit
#psef|grepinit
root10007:53?00:00:04/sb
in/init
root75086825011:48pts/100:00:00gre
pinit
#kill97508
29. rm command
#rmfilename
#rmitest.txt
rm:removeregularfile`test.txt'?
#mkdirdirectoryname
Ravi Saive
PREVIOUS STORY
NEXT STORY
(Nadia)
10 sFTP Command
Examples to Transfer
7 Quirky ls Command
Tricks Every Linux User
44
Rename A Command
Line Tool For Renaming
Files on Remote
Servers in Linux
Should Know
23 MAR, 2015
10 OCT, 2013
6 FEB, 2014
58 RESPONSES
Comments 58
Yoander
Pingbacks 0
i want to share my knowledge to the people because i want all people grow fast
in their life
Reply
Ravi Saive
@Sunil,
what kind of knowledge you want to share with the people? can you brief
us..
Reply
Tomas
This article is about useful commands for SYSADMINS and has no mention of
rsync? Seriously? :)
Reply
Ateeq
Hi,
I have a basic knowledge on Linux and Unix server. Want to enhance my
knowledge fully and become a Unix Admin or Linux Engineer. Could someone
please refer me the best book which is available in India Bangalore( Indian author
is better)
Reply
GrimReaper
There are enough low wage Indians thinking they know how to administer
Unix systems. Yet there foreign masters do not trust them to execute any
command without prior approval. I witnessed this scenario many times
while waiting for the Indian to call the manager at the client for approval.
Besides you can find the titles of a plethora of Unix administration books
via any Internet search engine.
Reply
Older Comments
LEAVE A REPLY
Name *
Email *
Website
Comment
Post Comment
28 OCT, 2014
26 MAY, 2014
22 MAR, 2014
13 MAY, 2015
17 JUN, 2014
16 AUG, 2012
25 FEB, 2015
Tecmint: Linux Howtos, Tutorials & Guides 2015. All Rights Reserved.
This work is licensed under a (cc) BY-NC
The material in this site cannot be republished either online or offline,
without our permission.