1. pwd command
Use the pwd command to find out the path of the current directory (folder) you’re
in. The command will return an absolute (full) path, which is basically a path that
starts with a forward slash (/). An example of an absolute path
2. cd command
To navigate through the Linux filesystem, use the cd command. It requires either
the full path or the name of the directory, depending on the current directory
Let’s say you’re in /home/username/Documents and want to go to Photos, a
subdirectory of Documents. To do so, simply type cd Photos.
Another scenario is if you want to switch to a completely new directory,
say /home/username/Movies. In this case, you have to type cd followed by the
directory’s absolute path.
There are some shortcuts if you want to navigate quickly. Use cd.. (with two dots)
to move one directory up, or go straight to the home folder with cd. To move to
your previous directory, type cd- (with a hyphen).
On a side note, Linux’s shell is case sensitive. Hence, you have to type the name’s
directory exactly as it is.
3. ls command
ls command is used to view the contents of a directory. By default, this command
will display the contents of your current directory.
If you want to see the content of other directories, type ls and then the directory’s
path. For example, enter ls /home/username/Documents to view the content
4. cat command
cat is one of the most frequently used command in Linux. It is used to view the
content of a file on the standard output (sdout). To run this command,
type cat followed by the file’s name and its extension. For instance: cat file.txt.
5. cp command
Use the cp command to copy files from the present directory. For instance, the
command cp scenery.jpg /home/username/Pictures would create a copy
of scenery.jpg to the Pictures directory.
6. mv command
The primary use of the mv command is to move files, although it can also be used
to rename files.
The arguments in this command are similar to the cp command. You need to
type mv, the file’s name, and the destination’s directory. For example: mv file.txt
To rename files, the syntax is mv oldname.ext newname.ext
7. mkdir command
Use mkdir command to make a new directory — like mkdir Music will create a new
directory called Music.
8. rmdir command
If you need to delete a directory, use the rmdir command. However, rmdir only
allows you to delete empty directories.
9. rm command
The rm command is used to delete directories along with the contents within
them. If you only want to delete the directory — as an alternative to rmdir —
use rm -r.
10. touch command
The touch command allows you to create blank new files through the command
line. As an example, enter touch /home/username/Documents/Web.html to
create an HTML file entitled Web under the Documents directory.
11. locate command
You can use this command to locate a file, just like the search command in
Windows. What’s more, using the -i argument along with this command will make
it case-insensitive, so you can search for a file even if you don’t remember its
To search for a file that contains two or more words, use an asterisk (*). For
example, locate -i school*note command will search for any file that contains the
word “school” and “note”, no matter if it is uppercase or lowercase.
12. find command
Similar to the locate command, using find also searches for files. The difference is,
you use the find command to locate files within a given directory.
As an example, find /home/ -name notes.txt command will search for a file
called notes.txt within the home directory and its subdirectories.
13. grep command
Another command that is undoubtedly very useful for everyday use. grep lets you
search through all the text through a given file.
To illustrate, grep blue notepad.txt will search for the word blue in the notepad
file. Lines that contain the searched word will be displayed fully.
14. sudo command
Short for “SuperUser Do”, this command enables you to perform tasks that require
administrative or root permissions. However, it is not advisable to use this
command for daily use because it might be easy for an error to occur if you did
15. df command
Use df command to get a report on the system’s disk space usage, shown in
percentage and KBs. If you want to see the report in megabytes, type df -m.
16. du command
If you want to check how much space a file or a directory takes, the du (Disk
Usage) command is the answer. However, the disk usage summary will show disk
block numbers instead of the usual size format. If you want to see it in bytes,
kilobytes, and megabytes, add the -h argument to the command line.
17. head command
The head command is used to view the first lines of any text file. By default, it
will show the first ten lines, but you can change this number to your liking. For
example, if you only want to show the first five lines, type head -n 5
18. tail command
This one has a similar function to the head command, but instead of showing the
first lines, the tail command will display the last ten lines of a text file.
19. diff command
Short for difference, the diff command compares the content of two files line by
line. After analyzing the files, it will output the lines that do not match.
Programmers often use this command when they need to make some program
alterations instead of rewriting the entire source code.
The simplest form of this command is diff file1.ext file2.ext
20. tar command
The tar command is the most widely used command to archive multiple files into
a tarball — a common Linux file format that is similar to zip format, but
compression is optional.
This command is quite complex with a long list of functions such as adding new
files into an existing archive, listing the content of an archive, extracting the
content from an archive, and many more. Check out some practical examples to
know more about other functions.
21. chmod command
chmod is another essential command, used to change the read, write, and execute
permissions of files and directories. As this command is rather complicated, you
can read the full tutorial in order to execute it properly.
22. chown command
In Linux, all files are owned by a specific user. The chown command enables you
to change or transfer the ownership of a file to the specified username. For
instance, chown linuxuser2 file.ext will make linuxuser2 as the owner of
23. jobs command
jobs command will display all current jobs along with their statuses. A job is
basically a process that is started by the shell.
24. kill command
If you have an unresponsive program, you can terminate it manually by using
the kill command. It will send a certain signal to the misbehaving app and instructs
the app to terminate itself.
There is a total of sixty-four signals that you can use, but people usually only use
SIGTERM (15) — requests a program to stop running and gives it some time
to save all of its progress. If you don’t specify the signal when entering the
kill command, this signal will be used.
SIGKILL (9) — forces programs to stop immediately. Unsaved progress will
Besides knowing the signals, you also need to know the process identification
number (PID) of the program you want to kill. If you don’t know the PID, simply
run the command ps ux.
After knowing what signal you want to use and the PID of the program, enter the
kill [signal option] PID.
25. ping command
Use the ping command to check your connectivity status to a server. For example,
by simply entering ping google.com, the command will check whether you’re able
to connect to Google and also measure the response time.
26. wget command
The Linux’s command line is super useful — you can even download files from the
internet with the help of the wget command. To do so, simply type wget followed
by the download link.
27. uname command
The uname command, short for Unix Name, will print detailed information about
your Linux system like the machine name, operating system, kernel, and so on.
28. top command
As a terminal equivalent to Task Manager in Windows, the top command will
display a list of running processes and how much CPU each process uses. It’s very
useful to monitor the system resource usage, especially knowing which process
needs to be terminated because it consumes too many resources.
29. history command
When you’ve been using Linux for a certain period of time, you’ll quickly notice
that you can run hundreds of commands every day. As such,
running history command is particularly useful if you want to review the
commands you’ve entered before.
30. man command
Confused about the function of certain commands? Don’t worry, you can easily
learn how to use them right from Linux’s shell by using the man command. For
instance, entering man tail will show the manual instruction of the tail command
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. The top command used to dipslay all the running and active real-time processes in ordered list and updates it regularly. It display CPU usage, Memory usage, Swap Memory, Cache Size, Buffer Size, Process PID, User, Commands and much more. It also shows high memory and cpu utilization of a running processess.
Linux VmStat command used to display statistics of virtual memory, kernerl threads, disks, system processes, I/O blocks, interrupts, CPU activity and much more. By default vmstat command is not available under Linux systems you need to install a package called sysstat that includes a vmstat program. The common usage of command format is.
Lsof – List Open Files
Lsof command used in many Linux/Unix like system that is used to display list of all the open files and the processes. The open files included are disk files, network sockets, pipes, devices and processes. One of the main reason for using this command is when a disk cannot be unmounted and displays the error that files are being used or opened. With this commmand you can easily identify which files are in use. The most common format for this command is.
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.
# tcpdump -i eth0
Netstat – Network Statistics
Netstat is a command line tool for monitoring incoming and outgoing network packets statistics as well as interface statistics. It is very useful tool for every system administrator to monitor network performance and troubleshoot network related problems.
# netstat -a | more
Htop – Linux Process Monitoring
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. Htop is a third party tool and doesn’t included in Linux systems, you need to install it using YUM package manager tool. For more information on installation read our article below.
7. Iotop – Monitor Linux Disk I/O
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.
8. Iostat – Input/Output Statistics
IoStat is simple tool that will collect and show system input and output storage device statistics. This tool is often used to trace storage device performance issues including devices, local disks, remote disks such as NFS.
ps – Displays the Linux processes
ps command will report a snapshot of the current processes. To select all processes use the -A or -e option:
# ps -A
Print All Process On The Server
# ps ax
# ps axu
Want To Print A Process Tree?
# ps -ejH
# ps axjf
Top 10 Memory Consuming Process
# ps -auxf | sort -nr -k 4 | head -10
Show Us Top 10 CPU Consuming Process
# ps -auxf | sort -nr -k 3 | head -10
6. free – Show Linux server memory usage
free command shows the total amount of free and used physical and swap memory in the system, as well as the buffers used by the kernel.
mpstat – Monitor multiprocessor usage on Linux
mpstat command displays activities for each available processor, processor 0 being the first one. mpstat -P ALL to display average CPU utilization per processor:
# mpstat -P ALL
pmap – Montor process memory usage on Linux
pmap command report memory map of a process. Use this command to find out causes of memory bottlenecks.
# pmap -d PID
To display process memory information for pid # 47394, enter:
# pmap -d 47394
/proc/ file system – Various Linux kernel statistics
/proc file system provides detailed information about various hardware devices and other Linux kernel information. See Linux kernel /proc documentations for further details. Common /proc examples:
# cat /proc/cpuinfo
# cat /proc/meminfo
# cat /proc/zoneinfo
# cat /proc/mounts
ifconfig utility is used to configure network interface parameters.
Mostly we use this command to check the IP address assigned to the system.
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). Ping use ICMP (Internet Control Message Protocol) to communicate to other devices. You can ping host name of ip address using below command.
# ping 126.96.36.199
7. ROUTE Command
route command also shows and manipulate ip routing table. To see default routing table in Linux, type the following command.
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.50.0 * 255.255.255.0 U 0 0 0 eth0
link-local * 255.255.0.0 U 1002 0 0 eth0
default 192.168.50.1 0.0.0.0 UG 0 0 0 eth0
Adding, deleting routes and default Gateway with following commands.
# route add -net 10.10.10.0/24 gw 192.168.0.1
# route del -net 10.10.10.0/24 gw 192.168.0.1
Adding default Gateway
# route add default gw 192.168.0.1
8. HOST Command
host command to find name to IP or IP to name in IPv4 or IPv6 and also query DNS records.
# host www.google.com
www.google.com has address 188.8.131.52
www.google.com has address 184.108.40.206
www.google.com has address 220.127.116.11
www.google.com has address 18.104.22.168
www.google.com has address 22.214.171.124
www.google.com has IPv6 address 2404:6800:4003:802::1014
Using -t option we can find out DNS Resource Records like CNAME, NS, MX, SOA etc.
# host -t CNAME www.redhat.com
www.redhat.com is an alias for wildcard.redhat.com.edgekey.net.
9. ARP 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.
# arp -e
Address HWtype HWaddress Flags Mask Iface
192.168.50.1 ether 00:50:56:c0:00:08 C eth0
10. ETHTOOL Command
ethtool is a replacement of mii-tool. It is to view, setting speed and duplex of your Network Interface Card (NIC). You can set duplex permanently in /etc/sysconfig/network-scripts/ifcfg-eth0 with ETHTOOL_OPTS variable.
# ethtool eth0
Settings for eth0:
Current message level: 0x00000007 (7)
Link detected: yes
11. IWCONFIG Command
iwconfig command in Linux is use to configure a wireless network interface. You can see and set the basic Wi-Fi details like SSID channel and encryption. You can refer man page of iwconfig to know more.
12. HOSTNAME Command
hostname is to identify in a network. Execute hostname command to see the hostname of your box. You can set hostname permanently in /etc/sysconfig/network. Need to reboot box once set a proper hostname.
# iwconfig [interface]
traceroute print the route packets take to network host.
Destination host or IP is mandatory parameter to use this utility
dig (Domain Information Groper) is a flexible tool for interrogating DNS name servers.
It performs DNS lookups and displays the answers that are returned from the name servers.
telnet connect destination host:port via a telnet protocol if connection establishes means connectivity between two hosts is working fine.
telnet geekflare.com 443
nslookup is a program to query Internet domain name servers.
[root@localhost ~]# nslookup geekflare.com
Netstat command allows you a simple way to review each of your network connections and open sockets.
netstat with head output is very helpful while performing web server troubleshooting.
[root@localhost ~]# netstat
nmap is a one of the powerful commands, which checks the opened port on the server.
Enable/Disable Network Interface
You can enable or disable the network interface by using ifup/ifdown commands with ethernet interface parameter.
To enable eth0
To disable eth0
Some Useful commands:
- arpwatch – Ethernet Activity Monitor.
- bmon – bandwidth monitor and rate estimator.
- bwm-ng – live network bandwidth monitor.
- curl – transferring data with URLs. (or try httpie)
- darkstat – captures network traffic, usage statistics.
- dhclient – Dynamic Host Configuration Protocol Client
- dig – query DNS servers for information.
- dstat – replacement for vmstat, iostat, mpstat, netstat and ifstat.
- ethtool – utility for controlling network drivers and hardware.
- gated – gateway routing daemon.
- host – DNS lookup utility
- hping – TCP/IP packet assembler/analyzer.
- ibmonitor – shows bandwidth and total data transferred.
- ifstat – report network interfaces bandwidth.
- iftop – display bandwidth usage.
- ip (PDF file) – a command with more features that ifconfig (net-tools).
- iperf3 – network bandwidth measurement tool. (above screenshot Stacklinux VPS)
- iproute2 – collection of utilities for controlling TCP/IP.
- iptables – take control of network traffic.
- IPTraf – An IP Network Monitor.
- iputils – set of small useful utilities for Linux networking.
- iw – a new nl80211 based CLI configuration utility for wireless devices.
- jwhois (whois) – client for the whois service.
- “⦁ lsof⦁ -⦁ i⦁ ” – reveal information about your network sockets.
- mtr – network diagnostic tool.
- net-tools – utilities include: arp, hostname, ifconfig, netstat, rarp, route, plipconfig, slattach, mii-tool, iptunnel and ipmaddr.
- ncat – improved re-implementation of the venerable netcat.
- netcat – networking utility for reading/writing network connections.
- nethogs – a small ‘net top’ tool.
- Netperf – Network bandwidth Testing.
- netsniff-ng – Swiss army knife for daily Linux network plumbing.
- netstat – Print network connections, routing tables, statistics, etc.
- netwatch – monitoring Network Connections.
- ngrep – grep applied to the network layer.
- nload – display network usage.
- nmap – network discovery and security auditing.
- nmcli – a command-line tool for controlling NetworkManager and reporting network status.
- nmtui – provides a text interface to configure networking by controlling NetworkManager.
- nslookup – query Internet name servers interactively.
- ping – send icmp echo_request to network hosts.
- slurm – network load monitor.
- snort – Network Intrusion Detection and Prevention System.
- smokeping – keeps track of your network latency.
- socat – establishes two bidirectional byte streams and transfers data between them.
- speedometer – Measure and display the rate of data across a network.
- speedtest-cli – test internet bandwidth using speedtest.net
- ss – utility to investigate sockets.
- ssh – secure system administration and file transfers over insecure networks.
- tcpdump – command-line packet analyzer.
- tcptrack – Displays information about tcp connections on a network interface.
- telnet – user interface to the TELNET protocol.
- tracepath – very similar function to traceroute.
- traceroute – print the route packets trace to network host.
- vnStat – network traffic monitor.
- websocat – Connection forwarder from/to web sockets to/from usual sockets, in style of socat.
- wget – retrieving files using HTTP, HTTPS, FTP and FTPS.
- Wireless Tools for Linux – includes iwconfig, iwlist, iwspy, iwpriv and ifrename.
- Wireshark – network protocol analyzer.