Linux Basic Commands
File Commands | |
ls | List Files and Directories |
ls -a | List all files including hidden files |
ls -l | List files in long format |
cd /path/to/dir | Change Directory to the Specified Path |
pwd | Print Current Working Directory |
mkdir dir_name | Create a New Directory |
rmdir dir_name | Remove a Directory |
rm file_name | Remove a File |
rm -r dir_name | Remove a Directory and its Contents |
touch file_name | Create a New File |
cat file_name | View the Contents of a File |
cp file_name target_file | Copy a file |
mv file_name target_file | Move and renames file |
SSH (Secure Shell) Commands | |
ssh user@host | Connect to a Remote Server using SSH |
ssh user@host -p port | Connect to a Remote Server using SSH with a Custom Port |
ssh-keygen -t rsa | Generate an SSH Key Pair |
Process Commands | |
ps | List Running Processes |
ps aux | grep process_name | List Processes with a Specific Name |
top | Display Running Processes |
kill pid | Kill a Process |
killall process_name | Kill All Processes with a Specific Name |
Search Commands | |
grep pattern files | Search for a Pattern in Files |
grep -r pattern dir | Search for a Pattern in Directories Recursively |
find /dir -name name* | Find Files and Directories with a Specific Name |
locate file_name | Find Files and Directories with a Specific Name |
File Permissions Commands | |
chmod +x file_name | Add Execution Permission to a File |
chmod 755 file_name | Set Read & Execute Permissions -> Owner and read -> others |
chown user:group file_name | Change Owner and Group of a File |
Network Commands | |
ping host | Send a Ping Request to a Host |
traceroute host | Display the Route Packets Taken to Network Host |
ifconfig | Display all network interfaces and IP addresses |
netstat -tulpn | Display listening ports and their application |
Archive & Compression Commands | |
tar cf archive_name.tar files | Create a Tar Archive from Files |
tar xf archive_name.tar | Extract Files from a Tar Archive |
gzip file_name | Compress a File and renames it to file_name.gz |
gunzip file_name.gz | Un-compress a File back |
System Info & Management Commands | |
uname -a | Display Operating System Details |
df -h | Display Disk Usage in human readable format |
du -sh dir_name | Display Disk Usage of a Directory in human readable format |
free -h | Display Free Memory in human readable format |
Package Management Commands (Debian/Ubuntu) | |
sudo apt-get update | Update the package list |
sudo apt-get upgrade | Upgrade all packages |
sudo apt-get install package_name | Install a Package |
sudo apt-get remove package_name | Remove a Package |
sudo apt-get purge package_name | Remove a Package and its Configuration |
sudo apt-get autoremove | Remove Unused Packages |
Text Editor Commands | |
nano file_name | Open a File in Nano Text Editor |
vim file_name | Open a File in Vim Text Editor |