Basics of Linux - Common Administration Commands
·
[Updated 7-3-2017]
Some basic commands that any system
administrator will use for the monitoring of systems and day to day administration tasks. Of course there are many many other commands that you can learn and use but you can start from these basic commands and then move forward.
Disks
df -h : To check the disk
usage/mounted partitions/available space
-h signifies 'Human Readable' so the disk sizes are displayed in MB and GB instead of bytes.
·
fdisk -l : list physical disk present and detected by the OS
*To fix a filesystem on any
partition:
fdisk -l : list physical disk present and detected by the OS
e2fsck –b [blocksize] /dev/partitionname
for example
e2fsck –b 4096 /dev/sda11
*Do not run the above e2fsck on any
mounted partition
iostat: To check the tps of disks,
Block reads, Blocks written per second
Sample Output:
· User Login Info
To check the current users
who are logged in to the machine:
who -r:
To check the run level of
machine
who -s:
To check the system load
and the uptime of server:
who -b: To show the boot time of the system
w and uptime:
uptime shows the total uptime of the system. The stats as you may have guessed :P are reset every time you reboot.
usually instead of using who or uptime, people just use w to get all the info in one go as it shows who's logged in, what process they are currently running the load on the system and the system uptime. So this is one powerful command.
last: To check the last n users
logged into server:
Processes
To check the memory, swap,
top processes:
top
To check the processes
running on the machine and searching for a specific process:
Standard Syntax
To see every process on the system using standard syntax:
ps -e
ps -ef
ps -eF
ps -ely
BSD Syntax
ps ax (will list all
running/sleeping/zombie processes)
ps ax | grep [process] for example to
search for ftp
ps ax | grep ftp
· To check the processor info:
cat /proc/cpuinfo
·
· Network
dig: Resolve domain names to IP
·
ping: test network connectivity and reach of a host
traceroute: see hop by hop traversal and performance of a packet to its destination
telnet: access a host on a specific port
ifconfig: view local ethernet configuration
route -n / ip route show
Files
To move a specific file
from one directory or another:
mv [filename] to /dir/filename
·
To copy a specific file
from one directory or another:
cp [filename] to /dir/
· To copy file from one
server to another:
scp [filename]
login@machineipaddress:/destinationdir
To read last [n] lines of
files:
tail –n [filename] for example to check the
last 200 lines of file:
tail -200f filename
·
To read first[n] lines of
files:
head –n [filename] for example to check the
first 200 lines of file:
head -200 filename
·
·
Comments
Post a Comment