Unix commands are a set of commands that are used to interact with the Unix operating
system. Unix is a powerful, multi-user, multi-tasking operating system that was developed
in the 1960s by Bell Labs. Unix commands are entered at the command prompt in a
terminal window, and they allow users to perform a wide variety of tasks, such as
managing files and directories, running processes, managing user accounts, and
configuring network settings. Unix is now one of the most commonly used Operating
systems used for various purposes such as Personal use, Servers, Smartphones, and
many more. It was developed in the 1970's at AT& T Labs by two famous personalities
Dennis M. Ritchie and Ken Thompson.
You'll be surprised to know that the most popular programming language C came into
existence to write the Unix Operating System.
Linux is Unix-Like operating system.
The most important part of the Linux is Linux Kernel which was first released in the
early 90s by Linus Torvalds. There are several Linux distros available (most are open-
source and free to download and use) such as Ubuntu, Debian, Fedora, Kali, Mint,
Gentoo, Arch and much more.
Now coming to the Basic and most usable commands of Linux/Unix part. (Please note
that all the linux/unix commands are run in the terminal of a linux system.Terminal is
like command prompt as that of in Windows OS)
Linux/Unix commands are case-sensitive i.e Hello is different from hello.
Basic Unix commands:
Table of Content
File System Navigation Unix Command
File Manipulation Unix Command
Process Management Unix Command
Text Processing Unix Command
Network Communication Unix Command
Text Editors in Unix
File System Navigation Unix Command
Command Description Example
cd Changes the current working directory. cd Documents
ls Lists files and directories in the current directory. ls
pwd Prints the current working directory. pwd
mkdir Creates a new directory. mkdir new_folder
rmdir Removes an empty directory. rmdir empty_folder
mv Moves files or directories. mv file1.txt Documents/
File Manipulation Unix Command
Command Description Example
Creates an empty file or updates the access and
touch new_file.txt
touch modification times.
cp Copies files or directories. cp file1.txt file2.txt
mv Moves files or directories. mv file1.txt Documents
rm Remove files or directories. rm old_file.txt
chmod Changes the permissions of a file or directory. chmod 644 file.txt
chown Changes the owner and group of a file or directory. chown user:group file.txt
ln Creates links between files. ln -s target_file symlink
cat Concatenates files and displays their contents. cat file1.txt file2.txt
head Displays the first few lines of a file. head file.txt
tail Displays the last few lines of a file. tail file.txt
more Displays the contents of a file page by page. more file.txt
Displays the contents of a file with advanced less file.txt
less navigation features.
diff Compares files line by line. diff file1.txt file2.txt
patch file.txt <
patch Applies a diff file to update a target file. changes.diff
Process Management Unix Command
Command Description Example
Displays information about active processes, including their ps aux
ps status and IDs.
Displays a dynamic real-time view of system processes and top
top their resource usage.
Command Description Example
kill Terminates processes using their process IDs (PIDs). kill <pid>
pkill -9
pkill Sends signals to processes based on name or other attributes. firefox
killall -9
killall Terminates processes by name. firefox
renice -n 10
renice Changes the priority of running processes. <pid>
nice -n 10
nice Runs a command with modified scheduling priority. command
pstree Displays running processes as a tree. pstree
pgrep Searches for processes by name or other attributes. pgrep firefox
jobs Lists active jobs and their status in the current shell session. jobs
bg Puts a job in the background. bg <job_id>
fg Brings a background job to the foreground. fg <job_id>
Runs a command immune to hangups, with output to a nohup command &
nohup specified file.
Removes jobs from the shell's job table, allowing them to run disown <job_id>
disown independently.
Text Processing Unix Command
Command Description Example
grep Searches for patterns in text files. grep "error" logfile.txt
sed 's/old_string/new_string/g'
sed Processes and transforms text streams. file.txt
Processes and analyzes text files using a awk '{print $1, $3}' data.csv
awk pattern scanning and processing language.
Network Communication Unix Command
Command Description Example
Tests connectivity with another host using ICMP ping google.com
ping echo requests.
Traces the route that packets take to reach a traceroute google.com
traceroute destination.
Queries DNS servers for domain name resolution nslookup google.com
nslookup and IP address information.
Performs DNS queries, providing detailed dig google.com
dig information about DNS records.
Performs DNS lookups, displaying domain name host google.com
host to IP address resolution.
Retrieves information about domain registration whois google.com
whois and ownership.
ssh Provides secure remote access to a system. ssh username@hostname
Securely copies files between hosts over a scp file.txt
scp network. username@hostname:/path/
Transfers files between hosts using the File ftp hostname
ftp Transfer Protocol (FTP).
Establishes interactive text-based communication telnet hostname
telnet with a remote host.
Displays network connections, routing tables,
interface statistics, masquerade connections, and netstat -tuln
netstat multicast memberships.
Displays or configures network interfaces and ifconfig
ifconfig their settings.
iwconfig Configures wireless network interfaces. iwconfig wlan0
route Displays or modifies the IP routing table. route -n
arp Displays or modifies the Address Resolution arp -a
Command Description Example
Protocol (ARP) cache.
ss Displays socket statistics. ss -tuln
hostname Displays or sets the system's hostname. hostname
Combines the functionality of ping and
traceroute, providing detailed network diagnostic mtr google.com
mtr information.
System Administration Unix Command
Command Description Example
df Displays disk space usage. df -h
du -sh
Displays disk usage of files and directories.
du /path/to/directory
Manages cron jobs, which are scheduled tasks that run at
crontab -e
crontab -e predefined times or intervals.
Text Editors in Unix
Text
Editor Description Example
Vi (Vim) is a highly configurable, powerful, and Open a file with Vim: vim
feature-rich text editor based on the original Vi filename
editor. Vim offers modes for both command-line Exit Vim editor: Press Esc, then
Vi / Vim operations and text editing. type :wq and press Enter
Open a file with Emacs: emacs
filename
Emacs is a versatile text editor with extensive Save and exit Emacs:
customization capabilities and support for various Press Ctrl + X, then Ctrl +
programming languages. S and Ctrl + X, then Ctrl +
Emacs C to exit
Open a file with Nano: nano
Nano is a simple and user-friendly text editor filename
designed for ease of use and accessibility. Save and exit Nano:
Nano Press Ctrl + O, then Ctrl + X
Text
Editor Description Example
Ed is a standard Unix text editor that operates in Open a file with Ed: ed
filename
line-oriented mode, making it suitable for batch Exit Ed editor: Type q and
Ed processing and automation tasks. press Enter
Open a file with Jed: jed
Jed is a lightweight yet powerful text editor that filename
provides an intuitive interface and support for Save and exit Jed: Press Alt +
various programming languages. X, then type exit and
Jed press Enter