Basic Linux Commands
13/10/2025
π File and Directory Navigation
Command | Description | Example |
---|---|---|
pwd | Print current working directory | pwd |
ls | List files and directories | ls -l |
cd | Change directory | cd Documents |
tree | Show directories as a tree (if installed) | Print the current working directory |
π File and Directory Management
Command | Description | Example |
---|---|---|
touch | Create an empty file | touch file.txt |
mkdir | Create a new directory | mkdir new_folder |
cp | Copy files or directories | cp file.txt copy.txt |
mv | Move or rename files/directories | mv file.txt folder/ |
rm | Remove files | rm file.txt |
rm -r | Remove directories recursively | rm -r folder |
π Viewing and Editing Files
Command | Description | Example |
---|---|---|
cat | View contents of a file | cat file.txt |
less | View the first lines of a file | less longfile.txt |
head | View the last lines of a file | head -n 10 file.txt |
tail | View last lines of a file | tail -n 10 file.txt |
nano / vim | Edit files in the terminal | View the file page by page |
βοΈ System and Process Management
Command | Description | Example |
---|---|---|
whoami | Show current logged user | whoami |
uname -a | Show system information | uname -a |
top or htop | Show running processes | top |
ps | Show your running processes | ps aux |
kill | Kill a process by PID | kill 1234 |
shutdown | Show the current logged user | Shut down the system |
π Networking Commands
Command | Description | Example |
---|---|---|
ping | Check network connectivity | ping google.com |
ifconfig / ip a | Show network interfaces | ip a |
curl | Fetch data from a URL | curl https://example.com |
wget | Download files from the web | wget https://example.com/file.zip |
π Searching and Finding
Command | Description | Example |
---|---|---|
find | Search for files and directories | find . -name file.txt |
grep | Search text in files | grep "word" file.txt |
locate | Quickly find file paths (uses a database) | locate file.txt |