Knowledge Base

Overview of Essential Linux Commands


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


1. File and Directory Management

List Files and Directories

ls
Options:

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

Change Directory

cd
Use cd .. to move up one level.

Print Current Directory

pwd

Create a Directory

mkdir

Remove a Directory

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

Copy Files or Directories

cp
Use cp -r for directories.

Move or Rename Files

mv

Delete Files

rm


2. File Viewing and Editing

View File Content

cat
Use tac <file_name> to display content in reverse.

Display File Content Page-by-Page

less

Display First or Last Lines of a File

head
tail

Edit Files

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


3. File Permissions and Ownership

View File Permissions

ls -l

Change Permissions

chmod
Examples:

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

Change Ownership

chown :


4. Process Management

View Running Processes

ps aux
Use top or htop for an interactive process viewer.

Kill a Process

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

Check System Resource Usage

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


5. Networking Commands

Check Network Interfaces and IP Address

ip a
Use ifconfig if ip is unavailable.

Test Network Connectivity

ping

Download Files from the Internet

wget
curl -O


6. Search and Find Commands

Search for Files

find -name

Search Inside Files

grep
Use grep -r <pattern> <directory> for recursive searches.


7. User Management

Add a New User

sudo adduser

Switch Users

su

Check Current User

whoami


8. 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


9. Archiving and Compression

Create a Tar Archive

tar -cvf .tar

Extract a Tar Archive

tar -xvf .tar

Compress Files with Gzip

gzip

Decompress Gzip Files

gunzip .gz


10. Package Management

Debian/Ubuntu-Based Systems

sudo apt-get update
sudo apt-get install

Red Hat/CentOS-Based Systems

sudo yum update
sudo yum install

Arch-Based Systems

sudo pacman -Syu
sudo pacman -S


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.

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

0 0