DEV Community

Cover image for Linux Commands You Should Master
Rubin
Rubin

Posted on

Linux Commands You Should Master

Linux commands form the backbone of navigating and managing a Linux system efficiently through the terminal. Whether you're a beginner or an experienced user, mastering these commands will greatly enhance your productivity and control over your system. In this article, here are the top Linux commands that every user should master for effective terminal usage

Navigation and File Management

cd: Change directory

  cd directory_name
Enter fullscreen mode Exit fullscreen mode

ls: List directory contents

ls options directory_path
Enter fullscreen mode Exit fullscreen mode

pwd: Print working directory

pwd
Enter fullscreen mode Exit fullscreen mode

cp: Copy files and directories

cp source_file destination_file
Enter fullscreen mode Exit fullscreen mode

mv: Move (rename) files and directories

mv source destination
Enter fullscreen mode Exit fullscreen mode

rm: Remove files and directories

rm file_name
Enter fullscreen mode Exit fullscreen mode

mkdir: Make directories

mkdir directory_name
Enter fullscreen mode Exit fullscreen mode

rmdir: Remove empty directories

rmdir directory_name
Enter fullscreen mode Exit fullscreen mode

cat: Concatenate and display files

cat file_name
Enter fullscreen mode Exit fullscreen mode

less/more: View file contents interactively (one screen at a time)

less file_name
more file_name
Enter fullscreen mode Exit fullscreen mode

head/tail: View the beginning or end of a file

head file_name
tail file_name
Enter fullscreen mode Exit fullscreen mode

grep: Search for patterns in files

grep pattern file_name
Enter fullscreen mode Exit fullscreen mode

find: Search for files in a directory hierarchy

find directory_path options
Enter fullscreen mode Exit fullscreen mode

ln: Create links between files

ln -s target_file link_name
Enter fullscreen mode Exit fullscreen mode

chmod: Change file permissions

chmod permissions file_name
Enter fullscreen mode Exit fullscreen mode

chown: Change file owner and group

chown owner:group file_name
Enter fullscreen mode Exit fullscreen mode

Process Management

ps: Display information about active processes

ps
Enter fullscreen mode Exit fullscreen mode

kill: Terminate processes

kill process_id
Enter fullscreen mode Exit fullscreen mode

top/htop: Display system processes in real-time

top
htop
Enter fullscreen mode Exit fullscreen mode

System Information

df: Display disk space usage

df options
Enter fullscreen mode Exit fullscreen mode

du: Estimate file space usage

du options file_name
Enter fullscreen mode Exit fullscreen mode

free: Display amount of free and used memory in the system

free
Enter fullscreen mode Exit fullscreen mode

uname: Print system information

uname -a
Enter fullscreen mode Exit fullscreen mode

uptime: Show how long the system has been running

uptime
Enter fullscreen mode Exit fullscreen mode

Network Management

ping: Check the connectivity to a server or network device

ping hostname_or_ip
Enter fullscreen mode Exit fullscreen mode

ifconfig/ip: Display and configure network interfaces

ip addr show
Enter fullscreen mode Exit fullscreen mode

netstat: Print network connections, routing tables, interface statistics, etc.

netstat options
Enter fullscreen mode Exit fullscreen mode

wget/curl: Download files from the internet

wget URL
curl -O URL
Enter fullscreen mode Exit fullscreen mode

System Administration

sudo: Execute a command as the superuser (root)

sudo command
Enter fullscreen mode Exit fullscreen mode

shutdown/reboot: Shutdown or reboot the system

shutdown options
reboot
Enter fullscreen mode Exit fullscreen mode

service/systemctl: Control system services (systemd-based systems)

systemctl start|stop|restart service_name
Enter fullscreen mode Exit fullscreen mode

journalctl: Query and display system logs

journalctl options
Enter fullscreen mode Exit fullscreen mode

passwd: Change user password

passwd
Enter fullscreen mode Exit fullscreen mode

Text Processing

awk: A versatile programming language for pattern scanning and processing

awk 'pattern { action }' file
Enter fullscreen mode Exit fullscreen mode

sed: Stream editor for filtering and transforming text

sed 's/search/replace/g' file
Enter fullscreen mode Exit fullscreen mode

cut: Remove sections from each line of files

cut options file
Enter fullscreen mode Exit fullscreen mode

sort: Sort lines of text files

sort options file
Enter fullscreen mode Exit fullscreen mode

uniq: Report or omit repeated lines

uniq options file
Enter fullscreen mode Exit fullscreen mode

wc: Print newline, word, and byte counts for each file

wc options file
Enter fullscreen mode Exit fullscreen mode

Compression and Archiving

tar: Archive files and directories

tar options archive_name files
Enter fullscreen mode Exit fullscreen mode

gzip/gunzip: Compress or decompress files

gzip file
gunzip file.gz
Enter fullscreen mode Exit fullscreen mode

bzip2/bunzip2: Another compression utility

bzip2 file
bunzip2 file.bz2
Enter fullscreen mode Exit fullscreen mode

Miscellaneous

echo: Display a line of text or variables

echo "Hello, world!"
Enter fullscreen mode Exit fullscreen mode

date: Display or set the system date and time

date
Enter fullscreen mode Exit fullscreen mode

watch: Execute a program periodically, showing output fullscreen

watch command
Enter fullscreen mode Exit fullscreen mode

alias: Create an alias for a command

alias short_name='command sequence'
Enter fullscreen mode Exit fullscreen mode

history: Display command history

history
Enter fullscreen mode Exit fullscreen mode

whoami: Display the current username

whoami
Enter fullscreen mode Exit fullscreen mode

touch: Change file timestamps or create empty files

touch file_name
Enter fullscreen mode Exit fullscreen mode

scp/rsync: Securely copy files between hosts

scp file user@host:destination
rsync options source destination
Enter fullscreen mode Exit fullscreen mode

Mastering these Linux commands will empower you to efficiently manage files, processes, networks, and more directly from the terminal. Whether you're a system administrator, developer, or Linux enthusiast, these commands are indispensable tools for your daily workflow.

Happy Linux command-line hacking!

Top comments (0)