| ls |
ls → List files & directories |
ls -l → Detailed listing |
|
ls -la → Show hidden files with details |
|
| cd |
cd dir → Change directory |
cd .. → Go up one level |
|
cd ~ → Go to home directory |
|
| pwd |
Show current directory path |
| cp |
cp file1 file2 → Copy file |
cp -r dir1 dir2 → Copy directory recursively |
|
| mv |
mv file newname → Rename file |
mv file /path/ → Move file |
|
| rm |
rm file → Delete file |
rm -r dir → Delete directory |
|
rm -rf dir → Force delete everything |
|
| mkdir / rmdir |
mkdir dir → Create directory |
mkdir -p path/dir → Create nested dirs |
|
rmdir dir → Remove empty directory |
|
| touch |
Create empty file / update timestamp |
| cat |
Display file content cat file1 file2 → Concatenate files |
| less |
View file content with navigation |
| head / tail |
head -n 10 file → First 10 lines |
tail -n 10 file → Last 10 lines |
|
tail -f file → Follow log updates |
|
| grep |
grep "text" file → Search text in file |
grep -r "text" dir/ → Recursive search in folder |
|
grep -rl "text" dir/ → Recursive search, list only matching filenames |
|
| find |
find /path -name "*.txt" → Find files by name |
find / -type d -name "dir" → Find directories |
|
| locate |
Quickly find files (uses database index) |
| chmod |
chmod 755 file → Change permissions |
chmod -R 644 dir/ → Apply recursively |
|
| chown |
chown user file → Change owner |
chown user:group file → Change owner & group |
|
| df / du |
df -h → Disk usage |
du -sh folder → Folder/file size |
|
| ps / top |
ps aux → List processes |
top → Live monitor |
|
htop → Interactive monitor |
|
| kill |
kill PID → Stop process |
kill -9 PID → Force kill |
|
| history |
Show previously used commands |
| man |
man command → Get help |
| uname |
uname -a → System info |
| whoami |
Show current user |
| echo |
Print text/variables (echo $HOME) |
| nano / vim |
Edit files in terminal |
| tar |
tar -czvf file.tar.gz dir → Compress |
tar -xzvf file.tar.gz → Extract |
|
| scp |
scp file user@host:/path → Copy files remotely |
| ssh |
ssh user@host → Connect to server |
| wget / curl |
wget URL → Download file |
curl URL → Fetch web/API data |
|
| awk |
awk '{print $1}' file → Print first column |
awk -F, '{print $2}' file.csv → Use delimiter (CSV) Powerful for text/data extraction |
|
| sed |
sed 's/old/new/' file → Replace first match in each line |
sed -i 's/old/new/g' file → Replace all (in-place) |
|
| yum |
yum install pkg → Install package (RHEL/CentOS) |
yum update → Update packages |
|
| sudo |
Run command with superuser privileges |
sudo command → Execute with root rights |
|
sudo -i → Open root shell |
|
| sudo apt |
sudo apt update → Refresh package list |
sudo apt upgrade → Upgrade all packages |
|
sudo apt install pkg → Install package |
|
sudo apt remove pkg → Remove package |
|
sudo apt autoremove → Remove unused dependencies |
|