Chapter V
Linux system and network
administration
Uptime Command
In Linux uptime command shows since how long your
system is running and the number of users those are
currently logged in and also displays load average for 1,
5 and 15 minutes intervals.
4
W Command
It will displays users currently logged in and their
process along-with shows load averages.
It also shows the login name, tty name, remote host,
login time, idle time and processes.
Who Command
Who command simply return user name, date, time and
host information. who command is similar to w
command.
Unlike w command, who doesn’t print what users are
doing.
Who Command
Who command Options
-b : Displays last system reboot date and time.
-a, –all : Displays all information in cumulatively.
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.
CP Command
MV Command
Cd command (change directory)
pwd command (print working directory)
SSH Command (Secure Shell)
SSH command is used to login into remote host. For
example the below ssh command will connect to remote
host (192.168.50.2) using user as narad.
Ftp or sftp Command
ftp or sftp command is used to connect to remote
ftp host.
ftp is (file transfer protocol) and sftp is (secure
file transfer protocol). For example the below
commands will connect to ftp host
(192.168.50.2).
Free command
last command
With last command we can watch user’s activity in the
system.
This command can execute normal user also.
It will display complete user’s info like terminal, time,
date, system reboot or boot and kernel version.
You can use last with username to know for
specific user’s activity as shown below.
kill command
Use kill command to terminate process. First find process
id with ps command as shown below and kill process
with kill -9 command.
rm command
Commands for Linux Network configuration
1. ifconfig:
Is used to initialize an interface,
Assign IP Address to interface and enable or disable
interface on demand. With this command you can view IP
Address and Hardware / MAC address assign to interface
and also MTU (Maximum transmission unit) size.
ifconfig with interface (eth0) command only shows specific
interface details like IP Address, MAC Address etc. with -a
options will display all available interface details if it is
disable also.
Ifconfig cont’d…
Ifconfig eth0
ifconfig eth0 down //to disable interface eth0
ifconfig eth0 up //to enable interface eth0
ifconfig eth0 add 192.168.1.101 //to assign ip address to
interface eth0
ifconfig eth0 netmask 255.255.255.0 //to assign subnet
mask to interface eth0
ifconfig eth0 // to display information configured with
eth0
To assign Ip address and subnet mask
PING Command
PING (Packet INternet Groper) command is the best way to test
connectivity between two nodes. Whether it is Local Area
Network (LAN) or Wide Area Network (WAN).
No basic network administration is effective without the ping
command.
I use it for testing server configuration and checking status. The
ping command basically sends test packets to a specific server
and checks if there is a response.
Ping cont’d…
NETSTAT Command
Netstat (Network Statistic) command display connection
info, routing table information etc.
To displays routing table information use option as -r.
netstat is available on all Unix-like Operating Systems
and also available on Windows OS as well.
It is very useful in terms of network troubleshooting and
performance measurement.
NSLOOKUP Command
nslookup is a command-line administrative tool
for testing and troubleshooting DNS servers
(Domain Name Server).
Route command
Route command also shows and manipulate ip
routing table. To see default routing table in
Linux, type the following command. It is
Equivalent to netstat –r.
Adding, deleting routes and default Gateway
with following commands.
HOST Command
host command to find name to IP or IP to name
in IPv4 or IPv6 and also query DNS records.
ARP (Address Resolution Protocol) Command
ARP (Address Resolution Protocol) is useful to view /
add the contents of the kernel’s ARP tables. To see
default table use the command as.
HOSTNAME Command
hostname is to identify in a network. Execute
hostname command to see the hostname of your box.
GUI tool system-config-network
Type system-config-network in command prompt to
configure network setting and you will get nice
Graphical User Interface (GUI) which may also used
to configure IP Address, Gateway, DNS etc. as shown
below image
Tcpdump – Network Packet Analyzer
Tcpdump one of the most widely used command-line
network packet analyzer or packets sniffer program that
is used capture or filter TCP/IP packets that received or
transferred on a specific interface over a network.
It also provides a option to save captured packages in a file
for later analysis.
tcpdump is almost available in all major Linux
distributions.
Command line tools for Linux Monitoring
1. Top – Linux Process Monitoring
Linux Top command is a performance monitoring
program which is used frequently by many system
administrators to monitor Linux performance and it is
available under many Linux/Unix like operating
systems.
Htop – Linux Process Monitoring
2. Htop is a much advanced interactive and real time Linux
process monitoring tool.
This is much similar to Linux top command but it has
some rich features like user friendly interface to
manage process, shortcut keys, vertical and
horizontal view of the processes and much more.
iotop – Monitor Linux Disk I/O
3. iotop
is also much similar to top command and Htop
program, but it has accounting function to monitor and
display real time Disk I/O and processes.
This tool is much useful for finding the exact process
and high used disk read/writes of the processes.
VmStat – Virtual Memory Statistics
4. VmStat command used to display statistics of virtual
memory, kernel threads, disks, system processes, I/O
blocks, interrupts, CPU activity and much more.
IPTraf – Real Time IP LAN Monitoring
5. IPTraf is an open source console-based real
time network (IP LAN) monitoring utility for
Linux.
iptraf
Monitorix – System and Network Monitoring
6. Monitorix is a free lightweight utility that is designed
to run and monitor system and network resources as
many as possible in Linux/Unix servers.
It has a built in HTTP web server that regularly collects
system and network information and display them in
graphs.
48