Knowledge Base

Overview of Essential Linux Commands

Linux logo

Linux commands form the backbone of using and managing a Linux system. This guide covers the most essential commands every Linux user should know.


File and Directory Management

List Files and Directories

ls

Options:

  • ls -l for detailed listing.
  • ls -a to include hidden files.

Change Directory

cd <directory_name>

Use cd .. to move up one level.

Print Current Directory

pwd

Create a Directory

mkdir <directory_name>

Remove a Directory

rmdir <directory_name>

Use rm -r <directory_name> for non-empty directories.

Copy Files or Directories

cp <source> <destination>

Use cp -r for directories.

Move or Rename Files

mv <source> <destination>

Delete Files

rm <file_name>

File Viewing and Editing

View File Content

cat <file_name>

Use tac <file_name> to display content in reverse.

Display File Content Page-by-Page

less <file_name>

Display First or Last Lines of a File

head <file_name>
tail <file_name>

Edit Files

nano <file_name>

Use vi <file_name> or vim <file_name> for advanced editing.

File Permissions and Ownership

View File Permissions

ls -l

Change Permissions

chmod <permissions> <file_name>

Examples:

  • chmod 755 <file_name>
  • chmod +x <file_name> to make a file executable.

Change Ownership

chown <user>:<group> <file_name>

Process Management

View Running Processes

ps aux

Use top or htop for an interactive process viewer.

Kill a Process

kill <process_id>

Use kill -9 <process_id> for a forced termination.

Check System Resource Usage

free -h for memory usage.
df -h for disk usage.

Networking Commands

Check Network Interfaces and IP Address

ip a

Use ifconfig if ip is unavailable.

Test Network Connectivity

ping <host_name_or_ip>

Download Files from the Internet

wget <url>
curl -O <url>

Search and Find Commands

Search for Files

find <directory> -name <file_name>

Search Inside Files

grep <pattern> <file_name>

Use grep -r<directory> for recursive searches.

User Management

Add a New User

sudo adduser <user_name>

Switch Users

su <user_name>

Check Current User

whoami

System Monitoring

Display System Uptime

uptime

View System Logs

journalctl

Use dmesg for kernel logs.

Check Disk Space Usage

df -h

Check Inode Usage

df -i

Archiving and Compression

Create a Tar Archive

tar -cvf <archive_name>.tar <files_or_directories>

Extract a Tar Archive

tar -xvf <archive_name>.tar

Compress Files with Gzip

gzip <file_name>

Decompress Gzip Files

gunzip <file_name>.gz

Package Management

Debian/Ubuntu-Based Systems

sudo apt-get update
sudo apt-get install <package_name>

Red Hat/CentOS-Based Systems

sudo yum update
sudo yum install <package_name>

Arch-Based Systems

sudo pacman -Syu
sudo pacman -S <package_name>

Learning these commands will help you become proficient in navigating and managing a Linux system.
Use the man command (e.g. man ls) for detailed information about any command.


Next: How to Monitor System Performance on Linux Using top covers reading what those commands report back.

If you have any questions, please contact our support team for assistance.

Please rate this article to help us improve our Knowledge Base.

0 0