50 Powerful Linux Commands You Must Know (With Examples)


This 50 powerful Linux commands cover everything you need to work confidently at the terminals, which are categorized into eight (8) different categories with examples that have been tested on RHEL, Rocky Linux, and Ubuntu . Additionally, each command example has working terminal output examples for your reference prior to executing the command.

Note

Unless otherwise specified all 50 of the commands described above are included as a standard installation component of RHEL, Rocky Linux, Ubuntu, Debian, and most other popular Linux distributions. All commands that are labeled as sudo can only be executed with root-level access; attempting to execute these commands as a non-root user will result in an error message stating Permission Denied. Please see the Note Box located in Section VIII for further information regarding this topic.

Table of Contents show

Examples

♥ Quick Navigation — Jump to Any Section
Section Topic Commands Covered
I 🗂 File & Directory Management ls, cd, pwd, mkdir, rm, cp, mv, find, touch, tree
II 📄 File Viewing & Text Processing cat, less, head, tail, grep, awk, sed, wc
III 🔐 File Permissions & Ownership chmod, chown, chgrp, umask
IV 📊 System Information & Monitoring top, htop, ps, df, du, free, uname, uptime
V ⚙️ Process Management kill, pkill, jobs, nohup
VI 🌐 Networking ping, curl, wget, ss, ip, ssh, scp, rsync
VII 📦 Package Management apt, dnf, rpm, snap
VIII 👤 Users & System Control sudo, useradd, passwd, dd

Most Linux users only scratch the surface; these 50 commands unlock real power

Start Here — 10 Commands for Absolute Beginners

If you are new to Linux we recommend starting with these ten (10) basic commands and become familiarized with them first. These ten (10) commands provide the ability to perform the majority of day-to-day operations directly within the terminal environment.

ls  ·  cd  ·  pwd  ·  mkdir  ·  cp  ·  mv  ·  cat  ·  grep  ·  sudo  ·  ssh

Once you are comfortable with these ten (10), then proceed to complete the remaining seven (7) sections. If you would like a more gentle introduction to learning Linux commands then check out our Linux Commands for Beginners Guide.

I

File & Directory Management

These ten (10) commands allow you to interact with the file system and include: create and remove files, copy and move data, and search for anything on disk. You will use them every single time you open a terminal.

#01

ls — List Files and Directories

The ls command which displays the contents of a directory. When combined with the -lah option it also displays: the size of the items contained within the directory in human readable format; their permissions; who owns them; what group they belong to; and when the item was modified. It also includes display of hidden files. For additional reading on how to properly utilize the ls command refer to our Basic ls Command Tutorial.

bash
ls -lah
Sample Output
total 48K
drwxr-xr-x 5 root root 4.0K Apr 10 09:14 .
drwxr-xr-x 18 root root 4.0K Apr 8 11:22 ..
-rw-r--r-- 1 root root 1.2K Mar 15 07:30 .bashrc
-rw-r--r-- 1 root root 512 Mar 15 07:30 .profile
drwxr-xr-x 3 root root 4.0K Apr 9 18:45 scripts
-rwxr-xr-x 1 root root 8.5K Apr 10 09:10 deploy.sh
Note

The -a flag includes hidden files (those starting with a dot). Use ls -la when you suspect a hidden config file or directory is present.

#02

cd — Change Directory

Using Absolute Paths and Relative Paths; The cd (change directory) command lets you move to different folders based on their absolute paths, relative paths, and shortcuts. Look to the cd command tips guide for more about how to navigate the folder structure with ease.

bash
cd /var/log
Tip

cd - takes you back to the previous directory. cd ~ or just cd takes you straight to your home directory. These two shortcuts save a lot of typing during long sessions.

#03

pwd — Print Working Directory

The pwd command will give you the full absolute path of where you're currently located. This is useful when you want to paste a path into a script or config file and don't have to guess the path.

bash
pwd
Sample Output
/var/log/nginx
Note

Use pwd -P to resolve symbolic links and print the actual physical path rather than the logical one.

#04

mkdir — Create a New Directory

The mkdir command creates new directories. When combined with -p , the mkdir command creates all parts of the directory tree needed to create a specified directory structure in a single command. It also won’t throw an error if any part of the directory already exists. Therefore, it’s safe to run this command in scripts.

bash
mkdir -p /opt/myapp/config
Tip

Create multiple directories at once with brace expansion: mkdir -p /opt/myapp/{config,logs,tmp} creates all three subdirectories in one go.

#05

rm — Remove Files or Directories

The rm (remove) command will delete files and folders. With -r it will remove the entire directory tree recursively. Also, there is no recycle bin (trash), no “undo”, and no prompts asking if you’re sure unless you add -i.

bash
rm -rf /tmp/old-files/
Danger — rm -rf Has No Undo

rm -rf permanently deletes everything at the path you give it, no trash, no confirmation, no recovery. A typo like rm -rf / tmp/ (accidental space) can wipe your entire system in seconds.

Always double-check the exact path before pressing Enter. Use rm -i for interactive confirmation on anything critical. Consider trash-cli for day-to-day removal so you have a recovery option.

#06

cp — Copy Files and Directories

The cp command will copy files and directories. Adding -r will make the cp command do a recursive copy. The -p option will preserve the original permissions, ownership, and timestamp(s) of the copied item(s). Use the file management commands guide to learn more about these patterns.

bash
cp -r /source/ /destination/
Tip

Use cp -rp when backing up a config directory before editing, it preserves all permissions and timestamps so you can restore the exact original state if something breaks.

#07

mv — Move or Rename Files

The mv command can be used to rename files and/or to move them. Since renaming/moving a file in the same file system is essentially updating the directory entry associated with that file’s name rather than actually moving/copying the file’s data itself, renaming/moving a file within the same file system is immediate.

bash
mv old-linuxteck.txt new-linuxteck.txt
Note

mv silently overwrites the destination if it already exists. Use mv -i for a confirmation prompt before overwriting, or mv -n to never overwrite an existing file.

#08

find — Search for Files by Name, Type, or Age

The find command searches for files in your file system that meet the criteria you specify, file name, file type, file size, file owner, file permissions, or date modified. In addition to being very useful for removing older logs, it is also useful for finding config files. The find command guide has much more information regarding searching for files using various parameters.

bash
find / -name "*.log" -mtime -1
Sample Output
/var/log/nginx/access.log
/var/log/nginx/error.log
/var/log/auth.log
/tmp/app-debug.log
Tip

Chain find with -exec to act on every result: find /var/log -name "*.log" -mtime +30 -exec rm {} \; deletes all log files older than 30 days. Always test with -print first before you commit.

#09

touch — Create an Empty File or Update Timestamp

The touch command will create an empty file if it doesn’t already exist. If it does exist, it will update its timestamps. Both functions are useful in scripts, creating placeholders and causing processes that depend upon the last-modified-date of a file to refresh the age of the file.

bash
touch linuxteck.txt
Note

Use brace expansion to create multiple files at once: touch linuxteck_{jan,feb,mar}.txt creates three files in one command.

#10

tree — Display Directory Structure as a Tree

The tree command displays your directory hierarchy graphically. By adding the -L you can limit how deep in the directory hierarchy the tree ommand will display. Without specifying this option, the tree command can generate hundreds of lines if you have a lot of subdirectories in your current working directory. To install tree if it isn’t installed yet, enter either of the two following commands: sudo apt install tree or sudo dnf install tree.

bash
tree -L 2 /etc/
Sample Output
/etc/
├── nginx
│ ├── nginx.conf
│ └── sites-enabled
├── ssh
│ ├── sshd_config
│ └── ssh_config
├── cron.d
│ └── dailyjobs
└── hosts

3 directories, 5 files

Tip

Use tree -L 2 -d to show only directories and skip files, helpful when you want to understand a project's folder structure without the noise of individual files.

II

File Viewing & Text Processing

All File Data is Stored as Text; Most Everything Is Stored As Text Files Under Linux. Configs, logs, scripts, and user databases are almost always stored as text files under Linux. And since you can read/search/filter/transform that text without having to open a GUI editor using the eight above-mentioned commands, they work very well together with pipes. For additional info, please refer to the text processing commands reference.

#11

cat — Display File Contents

The cat (concatenate) command is probably one of the fastest ways to print out the contents of a small config or script to the terminal. However, since cat sends all of the file at once, use less if you are dealing with larger files. The cat command guide rovides additional usage examples of cat.

bash
cat /etc/os-release
Sample Output
NAME="Ubuntu"
VERSION="22.04.3 LTS (Jammy Jellyfish)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 22.04.3 LTS"
VERSION_ID="22.04"
HOME_URL="https://www.ubuntu.com/"
Note

Use cat -n to display line numbers alongside the content, useful when referencing specific lines in a config file during troubleshooting.

#12

less — Scroll Through Large Files

The less command allows you to read a file in a scrolling environment, which means you can view files such as log files, man pages, and long config files page-by-page. Within less, search for a specific string by typing / followed by your search term and press Enter. Then press n to move down to the next occurrence of what you searched for.

bash
less /var/log/syslog
Tip

Press G to jump to the end, g to go back to the top, q to quit. Use less +F /var/log/syslog to follow a live log file, similar to tail -f but with the ability to scroll back through history.

#13

head — View the First N Lines of a File

The head (view header) command prints the first few lines of a file or ten lines by default but you may specify any number of lines after -n. A common use-case would be viewing several lines of a log file to verify whether the format matches expectations before running a batch job against it.

bash
head -20 /var/log/auth.log
Sample Output
Apr 10 08:01:12 webserver sshd[2241]: Accepted publickey for deploy from 203.0.113.45 port 54231 ssh2
Apr 10 08:01:12 webserver sshd[2241]: pam_unix(sshd:session): session opened for user deploy
Apr 10 08:05:33 webserver sudo: deploy : TTY=pts/0 ; PWD=/home/deploy ; USER=root ; COMMAND=/bin/systemctl restart nginx
Note

Combine head and tail to extract a range of lines from the middle of a file: head -50 linuxteck.txt | tail -10 gives you lines 41 through 50.

#14

tail — View Last N Lines and Follow Live Logs

The tail (view trailer) command views the last few lines of a file. The -f option will allow you to watch as data arrives in real-time, often useful when trying to reproduce problems while logging something in another window. For more ideas on tracking logs over time, please refer to the System Monitoring Cheat Sheet.

bash
tail -f /var/log/syslog
Tip

Use tail -f with grep to filter live output: tail -f /var/log/nginx/error.log | grep "502". You only see the lines you care about rather than every entry scrolling past.

#15

grep — Search Text Using Patterns

The grep command searches files or command output for lines matching a pattern. The -i flag makes the search case-insensitive, -r recurses through directories, and -n shows line numbers next to each match.

bash
grep -i "error" /var/log/syslog
Sample Output
Apr 10 09:11:02 webserver kernel: [12345.678] EXT4-fs error (device sda1): ...
Apr 10 09:13:44 webserver nginx[3312]: 2026/04/10 09:13:44 [error] 3312#3312: *1 connect() failed
Apr 10 09:15:01 webserver systemd[1]: Failed to start MySQL Database Server.
Tip

Use grep -v "pattern" to invert the match, showing only lines that do NOT contain the pattern. Useful for filtering health-check noise out of an access log so you can focus on real traffic.

#16

awk — Text Processing and Column Extraction

The awk command processes structured text, treating each line as a row of fields separated by a delimiter. Default is whitespace, change it with -F. It is the fastest way to pull a specific column out of command output or a structured file like /etc/passwd.

bash
awk -F: '{print $1}' /etc/passwd
Sample Output
root
daemon
bin
sys
sync
games
deploy
nginx
Note

$1 refers to the first field, $2 the second, and so on. $NF always refers to the last field regardless of how many columns there are.

#17

sed — Find and Replace in Files and Streams

The sed command reads text line by line and applies transformations. The most common use is find-and-replace: s/old/new/g. Add -i to edit a file in-place, extremely useful for config automation in scripts and Ansible playbooks. The sed commands guide covers more advanced patterns. If you find yourself running the same commands repeatedly, see our guide to the best open source automation tools for 2026 to take your workflows further.

bash
sed -i 's/old/new/g' linuxteck.txt
Tip

Test without -i first to preview output on screen before touching the file. On GNU/Linux use sed -i.bak to save a backup of the original file automatically before making changes.

#18

wc — Count Words, Lines, and Characters

The wc command counts lines, words, and characters in a file or stream. The -l flag counts only lines, the most common use case. Piping other commands into wc -l is a quick way to count almost anything.

bash
wc -l /etc/passwd
Sample Output
42 /etc/passwd
Note

ls /var/log | wc -l counts files in a directory. grep "Failed" /var/log/auth.log | wc -l counts failed login attempts. Both are common daily troubleshooting patterns.

III

File Permissions & Ownership

Linux permissions control who can read, write, and execute every file and directory. Getting them right is how you keep a server secure and prevent services from interfering with each other. The chmod command guide covers the full numeric and symbolic permission system.

#19

chmod — Change File Permissions

The chmod command sets who can read, write, and execute a file. In numeric notation each digit represents owner, group, and others; 4 is read, 2 is write, 1 is execute. So 755 means the owner can do everything while group and others can only read and execute.

bash
chmod 755 linuxteck.txt
♥ Quick Reference, chmod Numeric Values
Value Permission Symbol What It Allows
4 Read r View file contents or list directory
2 Write w Modify file or add/remove directory contents
1 Execute x Run file as a program or enter a directory
7 Full rwx Read + Write + Execute
6 Read+Write rw- View and modify, but not execute
5 Read+Exec r-x View and run, but not modify
0 None --- No access at all
Note

chmod changes permissions only; not ownership. Use chown or chgrp for that. Use chmod -R 755 /path/ to apply recursively to an entire directory tree.

#20

chown — Change File Ownership

The chown command changes the owner and optionally the group of a file or directory. You need root or sudo to use it on files you do not own. The format is user:group, set both at once, or leave off the group to change only the owner.

bash
chown user:group linuxteck.txt
Tip

chown -R nginx:nginx /var/www/mysite/ is one of the most common fixes for a "403 Forbidden" error, it sets the correct ownership so the web server can read the files it needs.

#21

chgrp — Change Group Ownership

The chgrp command changes only the group ownership of a file, leaving the user owner unchanged. Useful in shared environments where multiple users work in the same project directory via a shared group.

bash
chgrp developers project/
Note

Use chgrp -R developers /opt/project/ to apply the group change recursively. Verify with ls -la /opt/project/ and check the group column in the output.

#22

umask — Set Default Permission Mask

The umask command controls what permissions are removed from newly created files and directories. A umask of 022 subtracts write from group and others, resulting in files created as 644 and directories as 755, the standard default on most Linux systems.

bash
umask 022
Note

Run umask with no arguments to see the current setting. For tighter security, some teams use 027 to remove group write and all other permissions from new files.

IV

System Information & Monitoring

When something goes wrong, the first thing you need is visibility. These 8 commands show you CPU, memory, disk, and uptime in seconds. The system monitoring cheat sheet and the best Linux monitoring tools guide cover more advanced options.

#23

top — Real-Time Process Monitor

The top command is the built-in real-time process monitor on virtually every Linux system. It shows CPU, memory, load average, and a sorted list of running processes — usually the first place you check when a server is slow. See the top command guide for shortcuts and filtering options.

bash
top
Sample Output
top - 09:31:04 up 12 days, 3:22, 2 users, load average: 0.42, 0.38, 0.35
Tasks: 183 total, 1 running, 182 sleeping, 0 stopped, 0 zombie
%Cpu(s): 3.1 us, 1.2 sy, 0.0 ni, 95.4 id, 0.2 wa, 0.0 hi, 0.1 si
MiB Mem : 3929.8 total, 412.1 free, 1832.4 used, 1685.3 buff/cache
MiB Swap: 2048.0 total, 2048.0 free, 0.0 used. 1914.5 avail Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
3311 nginx 20 0 123456 45678 8900 S 2.3 1.1 12:03.22 nginx
1234 mysql 20 0 876543 345678 12345 S 1.1 8.8 89:12.44 mysqld

Tip

While top is running: press P to sort by CPU, M to sort by memory, k to kill a process by PID, and q to quit.

#24

htop — Interactive Process Viewer

The htop command is an improved, color-coded, mouse-enabled version of top. It shows per-core CPU bars, displays memory visually, and lets you scroll, filter, and kill processes interactively. Install with sudo apt install htop or sudo dnf install htop.

bash
htop
Note

Press F6 to change sort column, F4 to filter by process name, F9 to send a signal, q to quit. See the useful Linux terminal commands guide for more.

#25

ps — List Running Processes

The ps command gives a snapshot of running processes at the moment you run it. ps aux shows every process from all users including the command that started it. Pipe into grep to check if a service is running and get its PID. The ps command guide covers more filtering options.

bash
ps aux | grep nginx
Sample Output
root 3311 0.0 0.3 123456 12345 ? Ss 08:01 0:00 nginx: master process
nginx 3312 0.2 1.1 134567 45678 ? S 08:01 0:12 nginx: worker process
nginx 3313 0.2 1.1 134567 45678 ? S 08:01 0:12 nginx: worker process
Note

The grep process itself appears in the results. Use the bracket trick to filter it out: ps aux | grep [n]ginx, the pattern does not match the grep command itself.

#26

df — Show Disk Space Usage

The df command reports disk space used and available on each mounted filesystem. The -h flag shows sizes in GB/MB. Running out of disk space is one of the most common causes of sudden service failures, df -h belongs on every troubleshooting checklist. See the df command guide.

bash
df -h
Sample Output
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 50G 32G 16G 67% /
/dev/sda2 100G 88G 12G 88% /var
tmpfs 2.0G 1.1M 2.0G 1% /run/shm
Tip

If a filesystem shows 88% or higher, use du -sh /* 2>/dev/null | sort -rh | head -20 to find the top 20 largest directories from root, usually points straight to the culprit.

#27

du — Show Directory Disk Usage

The du command shows how much disk space a directory and its contents use. Where df shows filesystem totals, du drills down to individual directories. The -s flag shows a summary total, -h keeps sizes readable. See the du command guide.

bash
du -sh /var/log/
Sample Output
4.3G /var/log/
Note

Run du -sh /var/log/* | sort -rh to sort all subdirectories from largest to smallest, the fastest way to identify a bloated log directory.

#28

free — Display Memory Usage

The free command shows how much RAM and swap is used and available. The "available" column is more meaningful than "free", Linux uses spare RAM for disk caching, and that cache is released immediately when a process needs it.

bash
free -h
Sample Output
total used free shared buff/cache available
Mem: 3.8Gi 1.8Gi 412Mi 88Mi 1.6Gi 1.8Gi
Swap: 2.0Gi 0B 2.0Gi
Tip

If the system is using swap, RAM is under real pressure. Watch the "available" column, when it approaches zero, services start competing for memory and performance degrades fast.

#29

uname — Show System and Kernel Information

The uname command reports the kernel version and system architecture. The -r flag shows just the kernel release, what you need most when checking compatibility or researching a kernel bug. Use -a to show everything at once.

bash
uname -r
Sample Output
5.15.0-101-generic
Note

Combine uname -r with cat /etc/os-release for the full picture, kernel version plus distro version covers everything needed for a bug report or known-issue search.

#30

uptime — Show How Long the System Has Been Running

The uptime command prints system uptime, logged-in user count, and load averages for the last 1, 5, and 15 minutes. A load average roughly equal to the number of CPU cores means the system is fully utilized — higher means processes are waiting.

bash
uptime
Sample Output
09:45:12 up 12 days, 3:36, 2 users, load average: 0.55, 0.48, 0.41
Tip

A load average at 2x or more your CPU core count that holds steady is a real bottleneck, move to top or htop to identify which processes are responsible.

V

Process Management

These 4 commands let you stop processes by ID or name, check what is running in the background, and keep long-running tasks alive after you disconnect. For more patterns, see the Linux process management cheat sheet.

#31

kill — Send a Signal to a Process by PID

The kill command sends a signal to a process by PID. Signal -15 (SIGTERM) asks the process to shut down gracefully. Signal -9 (SIGKILL) forces immediate termination with no cleanup. Always try -15 first.

bash
kill -9 1234
Note

Find a process PID with ps aux | grep processname, the shorter pgrep processname, or pidof nginx for named processes.

#32

pkill — Kill Processes by Name

The pkill command kills processes by name pattern, no need to look up a PID first. It sends the signal to all matching processes, which is handy when a service has multiple worker processes.

bash
pkill nginx
Tip

Run pgrep processname before pkill, it shows which PIDs would match without sending any signal, so you can confirm you are targeting the right processes.

#33

jobs — List Background Jobs

The jobs command shows processes you have sent to the background using & or Ctrl+Z. Each job gets a number you can use with fg %1 to bring it to the foreground, or bg %1 to resume it in the background. The -l flag also shows each job's PID.

bash
jobs -l
Sample Output
[1] + 4521 Running ./backup.sh &
[2] - 4789 Stopped vi linuxteck.txt
Note

Background jobs are tied to your current shell session, close the terminal and they stop. Use nohup or a process manager like tmux, screen, or systemd for jobs that must survive logout.

#34

nohup — Run a Command Immune to Hangups

The nohup command makes a process ignore the SIGHUP signal sent when your SSH session ends, so it keeps running after you log out. Combine with & to send it to the background immediately. Output goes to nohup.out by default unless you redirect it.

bash
nohup ./script.sh &
Tip

Redirect to a named log file to avoid nohup.out piling up: nohup ./script.sh > /var/log/myjob.log 2>&1 &. The 2>&1 captures stderr into the same file so errors are not lost.

VI

Networking

Networking commands are core sysadmin skills on Linux. These 8 commands cover connectivity testing, file transfers, port inspection, SSH access, and remote file synchronization. For a deeper look, see the Linux network administration guide and the 8 Linux networking commands guide.

#35

ping — Test Network Connectivity

The ping command sends ICMP echo packets to a host and reports round-trip time. It is the quickest check for whether a host is reachable. The -c 4 flag limits the test to 4 packets so it stops automatically.

bash
ping -c 4 google.com
Sample Output
PING google.com (142.250.80.46) 56(84) bytes of data.
64 bytes from lga34s32-in-f14.1e100.net: icmp_seq=1 ttl=118 time=12.4 ms
64 bytes from lga34s32-in-f14.1e100.net: icmp_seq=2 ttl=118 time=11.9 ms
64 bytes from lga34s32-in-f14.1e100.net: icmp_seq=3 ttl=118 time=12.1 ms
64 bytes from lga34s32-in-f14.1e100.net: icmp_seq=4 ttl=118 time=12.3 ms

--- google.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3005ms
rtt min/avg/max/mdev = 11.9/12.2/12.4/0.2 ms

Note

If pinging a hostname fails but the IP responds, the problem is DNS resolution, not network connectivity. That distinction saves a lot of debugging time.

#36

curl — Transfer Data from URLs

The curl command transfers data to or from a URL over HTTP, HTTPS, FTP, and more. Use it to test API endpoints, check HTTP response headers, and download files from the command line. The -I flag fetches headers only, great for quickly checking a server's status code. See the curl command guide for more patterns.

bash
curl -I https://linuxteck.com
Sample Output
HTTP/2 200
server: nginx
date: Thu, 10 Apr 2026 09:45:01 GMT
content-type: text/html; charset=UTF-8
x-powered-by: PHP/8.1.27
link: <https://www.linuxteck.com/wp-json/>; rel="https://api.w.org/"
Tip

Use curl -o linuxteck.txt https://example.com/file to save output to a named file. Use curl -L to follow redirects, without it, curl stops at the first redirect response.

#37

wget — Download Files from the Web

The wget command downloads files from the web and saves them to disk automatically. It supports resuming interrupted downloads with -c and background downloads with -b, the go-to tool on headless servers with no browser.

bash
wget https://example.com/file.tar.gz
Note

Use wget -c URL to resume an interrupted download, particularly useful for large ISO images where restarting from the beginning wastes significant time and bandwidth.

#38

ss — Show Listening Ports and Connections

The ss command is the modern replacement for netstat. The flags -tlnp show TCP listening ports with the process name and PID attached, the combination you will reach for most often. See the Linux network command cheat sheet for more examples.

bash
ss -tlnp
Sample Output
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:22 0.0.0.0:* users:(("sshd",pid=1022,fd=3))
LISTEN 0 511 0.0.0.0:80 0.0.0.0:* users:(("nginx",pid=3311,fd=6))
LISTEN 0 511 0.0.0.0:443 0.0.0.0:* users:(("nginx",pid=3311,fd=8))
LISTEN 0 70 127.0.0.1:3306 0.0.0.0:* users:(("mysqld",pid=4123,fd=21))
Tip

If a service should be listening but you cannot connect, run ss -tlnp first. Port absent means the service is not running. Port present means the problem is likely a firewall rule.

#39

ip — Show and Configure Network Interfaces

The ip command is the modern replacement for ifconfig. It shows and configures network interfaces, IP addresses, and routing tables. The most common use is ip addr show to see what addresses are assigned to each interface.

bash
ip addr show
Sample Output
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP
link/ether 00:1a:2b:3c:4d:5e brd ff:ff:ff:ff:ff:ff
inet 192.168.1.105/24 brd 192.168.1.255 scope global eth0
Note

Use ip route show to view the routing table and confirm the default gateway. Changes made directly with the ip command do not persist across reboots, edit your network config files for permanent changes.

#40

ssh — Connect to a Remote Machine Securely

The ssh command opens an encrypted terminal session to a remote Linux machine, how virtually all remote server management is done. Authenticate with a password or, much better, an SSH key pair. The SSH client commands guide and the install and secure SSH server guide cover key setup and hardening.

bash
ssh user@192.168.1.10
Tip

Use ~/.ssh/config to define server aliases. Instead of typing ssh -i ~/.ssh/mykey.pem user@203.0.113.45 -p 2222 every time, define a host block and just type ssh myserver.

#41

scp — Copy Files Over SSH

The scp command copies files between machines over an encrypted SSH connection. The syntax mirrors cp with a user@host: prefix for the remote side. It uses the same authentication as SSH, password or key.

bash
scp linuxteck.txt user@host:/remote/path/
Note

Use scp -r to copy an entire directory recursively. For large transfers or when you need resuming and bandwidth control, rsync is a better choice than scp.

#42

rsync — Sync Files Locally or Over SSH

The rsync command synchronizes files and directories, transferring only what has changed. This makes it much faster than scp or cp for large directory trees where only a few files have been updated. The -avz flags enable archive mode, verbose output, and compression.

bash
rsync -avz /local/ user@host:/remote/
Tip

Always run rsync with --dry-run the first time on an important sync to see what would transfer before it happens. Add --delete only after verifying the dry run, it removes files at the destination that no longer exist at the source. See the Linux server backup solutions guide for more strategies.

VII

Package Management

Package managers handle installing, updating, and removing software on Linux. Debian and Ubuntu use apt, RHEL and Fedora use dnf, and snap works across distributions. The Linux package management cheat sheet has a full comparison of flags across all package managers.

#43

apt — Package Manager for Debian / Ubuntu

The apt command is the primary package manager on Debian-based systems. Always run sudo apt update first to refresh the package list before installing or upgrading, otherwise you may get outdated versions or errors about packages that cannot be found.

bash
sudo apt install nginx -y
Note

sudo apt upgrade upgrades all installed packages. sudo apt remove packagename removes a package but keeps config files. sudo apt purge packagename removes both. Use apt list --installed to see everything currently on the system.

#44

dnf — Package Manager for RHEL / Fedora

The dnf command is the package manager for RHEL 8+, CentOS Stream, Rocky Linux, AlmaLinux, and Fedora. It replaced yum starting with RHEL 8, most syntax is identical. The DNF guide for beginners is a good next step for RPM-based systems.

bash
sudo dnf install httpd -y
Tip

Use dnf search packagename to find the correct package name before installing. dnf history shows a complete log of every package transaction so you can undo or review changes.

#45

rpm — Query and Manage RPM Packages

The rpm command works directly with the RPM package database. While dnf handles dependencies and repositories, rpm is useful for querying what is installed, verifying package integrity, and installing individual .rpm files. The -qa flags list every package currently installed.

bash
rpm -qa | grep python
Sample Output
python3-3.9.18-3.el8.x86_64
python3-pip-21.3.1-6.el8.x86_64
python3-setuptools-53.0.0-12.el8.noarch
python3-libs-3.9.18-3.el8.x86_64
Note

Use rpm -qi packagename for detailed package info. Use rpm -ql packagename to list all files a package installed, useful for finding where a binary or config file was placed.

#46

snap — Manage Snap Packages

The snap command manages self-contained, sandboxed application bundles that work across multiple Linux distributions. Snaps bundle their own dependencies, so the same package installs identically on Ubuntu, Fedora, Debian, and others without conflicts. The tradeoff is larger package size and potentially slower startup.

bash
snap install vlc
Note

Use snap list to see installed snaps, snap find packagename to search the Snap Store, and sudo snap remove packagename to uninstall. snapd comes pre-installed on Ubuntu but may need adding on other distributions.

VIII

Users, Permissions & System Control

Managing users and running system-level operations requires elevated privileges. These commands are where mistakes can have serious consequences; read the notes carefully. The user management cheat sheet and the steps to configure sudo guide are worth reading alongside this section.

Root vs User Commands — What Needs sudo?

Commands that modify system-wide settings, install software, manage user accounts, or access restricted files require sudo. Running them as a regular user returns a Permission denied error. Commands like ls, grep, find, cat, ping, and curl run fine without elevated privileges for files and resources you already have access to.

As a general rule: if a command changes system state or touches files outside your home directory, it probably needs sudo. You will be prompted for your password the first time, subsequent commands in the same session use a short cached window.

#47

sudo — Run Commands as Superuser

The sudo command runs a single command with root privileges without switching you to the root account permanently. It logs every privileged action, creating an audit trail. This is far safer than logging in as root and is the standard way to perform administrative tasks on modern Linux.

bash
sudo systemctl restart nginx
Tip

Use sudo -l to see what commands your user can run with sudo. Use sudo -i to start an interactive root shell for a series of privileged commands, exit when done so you are not in a root shell longer than needed.

#48

useradd — Create a New User

The useradd command creates a new user account. The -m flag creates the home directory automatically and -s /bin/bash sets bash as the default shell. Without -m the user has no home directory, which causes login problems. Always set a password with passwd immediately after. See the create user guide for UID, group, and expiry options.

bash
sudo useradd -m -s /bin/bash newuser
Note

On Debian and Ubuntu, consider using adduser instead, it walks you through all options interactively and sets up the home directory automatically. On RHEL and CentOS, useradd -m is the standard approach.

#49

passwd — Change User Password

The passwd command changes a user's password. Run without arguments to change your own. Run with a username as root or with sudo to change another user's password. A newly created user has a locked account until a password is set, passwd is always the step right after useradd.

bash
sudo passwd newuser
Sample Output
New password:
Retype new password:
passwd: password updated successfully
Tip

Use sudo passwd -l username to lock an account without deleting it — the user can no longer log in with a password. Use sudo passwd -u username to unlock it again.

#50

dd — Copy and Convert Raw Data / Disk Images

The dd command copies raw data at a low level between an input source (if=) and an output destination (of=). It is used for creating disk images, cloning drives, and writing bootable ISO images to USB drives. The bs=4M flag sets the block size which affects transfer speed.

bash
dd if=/dev/sda of=/dev/sdb bs=4M
Danger — dd Can Wipe Entire Disks With No Undo

Getting if= and of= backwards or pointing of= at the wrong device; overwrites the target disk completely and silently. There is no confirmation, no warning, and no recovery. A single typo can destroy a system.

Before running any dd command, use lsblk to confirm exact device names. Double-check both arguments. Never run dd in a hurry. When creating a backup image, always point of= to a file path, not a device.

Conclusion:

Thanks for reading! Hope this breakdown of 50 Linux commands saves you some time at the terminal. If you found it useful, share it with someone who is just getting started with Linux. Drop your questions or feedback in the comments below.

LinuxTeck: A Complete Linux Learning Blog
From your first terminal command to advanced sysadmin skills. Every guide here is written in plain English with real examples you can run right now.



About Sharon J

Sharon J is a Linux System Administrator with strong expertise in server and system management. She turns real-world experience into practical Linux guides on Linux Teck.

View all posts by Sharon J →

Leave a Reply

Your email address will not be published.

L