Basic Linux Commands with Examples
pwd - Prints the current working directory.
Example: pwd
ls - Lists files and directories.
Example: ls -l
cd - Changes the current directory.
Example: cd /home/user
mkdir - Creates a new directory.
Example: mkdir new_folder
rmdir - Removes an empty directory.
Example: rmdir old_folder
touch - Creates a new file.
Example: touch file.txt
rm - Deletes files or directories.
Example: rm file.txt
cp - Copies files or directories.
Example: cp source.txt dest.txt
mv - Moves or renames files.
Example: mv oldname.txt newname.txt
cat - Displays contents of a file.
Example: cat file.txt
echo - Displays a line of text.
Example: echo 'Hello, World!'
clear - Clears the terminal.
Example: clear
man - Displays the manual for a command.
Example: man ls
whoami - Displays current user.
Example: whoami
chmod - Changes file permissions.
Example: chmod 755 file.sh
chown - Changes file ownership.
Example: chown user:user file.txt
exit - Closes the terminal.
Example: exit
Advanced Linux Commands with Examples
grep - Searches for patterns in files.
Example: grep 'main' file.c
find - Finds files/directories.
Example: find . -name '*.txt'
awk - Processes and analyzes text files.
Example: awk '{print $1}' file.txt
sed - Edits streams of text.
Example: sed 's/old/new/g' file.txt
tar - Archives files.
Example: tar -cvf archive.tar file1 file2
gzip/gunzip - Compresses/decompresses files.
Example: gzip file.txt
top - Displays running processes.
Example: top
ps - Shows running processes.
Example: ps aux
kill - Terminates processes.
Example: kill 1234
df - Shows disk space.
Example: df -h
du - Shows directory usage.
Example: du -sh *
ssh - Connects to remote host.
Example: ssh user@192.168.1.10
scp - Securely copies files.
Example: scp file.txt user@host:/path
wget - Downloads from web.
Example: wget http://example.com/file.txt
curl - Transfers data from/to server.
Example: curl https://example.com
cron - Schedules tasks.
Example: crontab -e
journalctl - Views logs.
Example: journalctl -xe