Linux Basics: A Beginner’s Guide to Essential Commands
pwd
– Print Working DirectoryShows the current directory (folder) you're in.
pwd
Example Output:
/home/username
ls
– List Directory ContentsLists files and directories in the current folder.
ls # Basic list
ls -l # Detailed list (permissions, size, etc.)
ls -a # Shows hidden files (starting with '.')
cd
– Change DirectoryMoves you into a different directory.
cd Documents # Move into "Documents"
cd .. # Go up one directory
cd ~ # Return to home directory
cd / # Go to the root directory
mkdir
– Make DirectoryCreates a new folder.
mkdir new_folder
touch
– Create a FileCreates an empty file.
touch file.txt
cp
– Copy Files/DirectoriesCopies a file or directory.
cp file.txt /backup/ # Copy file to another location
cp -r folder/ backup/ # Copy a directory recursively
mv
– Move or Rename FilesMoves files or renames them.
mv file.txt new_name.txt # Rename
mv file.txt ~/Documents/ # Move to another directory
rm
– Remove Files/DirectoriesDeletes files or directories (use with caution!).
rm file.txt # Delete a file
rm -r folder/ # Delete a directory and its contents
cat
– Display File ContentsPrints the contents of a file.
cat file.txt
less
/ more
– View Files Page by PageAllows scrolling through large files.
less long_file.txt
more long_file.txt
nano
/ vim
– Text EditorsSimple text editors for modifying files.
nano file.txt # Easy-to-use editor
vim file.txt # More advanced (press `i` to edit, `Esc` then `:wq` to save & exit)
df
– Disk Space UsageShows disk space on mounted filesystems.
df -h # Human-readable format (MB/GB)
free
– Memory UsageDisplays RAM and swap usage.
free -h
top
/ htop
– Process MonitorLists running processes (press q
to exit).
top # Basic process viewer
htop # More interactive (may need installation)
ps
– Process StatusLists currently running processes.
ps aux # Detailed process list
chmod
– Change File PermissionsModifies read (r
), write (w
), and execute (x
) permissions.
chmod +x script.sh # Make a file executable
chmod 755 file.txt # Sets permissions numerically (rwxr-xr-x)
chown
– Change File OwnerChanges the owner of a file/directory.
sudo chown user:group file.txt
ping
– Test Network ConnectionChecks connectivity to a server.
ping google.com
ifconfig
/ ip
– Network Interface InfoDisplays network interfaces and IP addresses.
ifconfig # Older command (may require installation)
ip a # Modern alternative
wget
/ curl
– Download FilesDownloads files from the internet.
wget https://example.com/file.zip
curl -O https://example.com/file.zip
apt
– Install/Remove SoftwareManages packages on Debian-based systems.
sudo apt update # Update package list
sudo apt install package # Install a package
sudo apt remove package # Remove a package
These basic Linux commands will help you get started with file management, system navigation, and troubleshooting. As you become more comfortable, you can explore more advanced commands and scripting.
Have questions or need further explanations? Drop a comment below!
Happy Linux-ing!
Did you find this helpful? Share it with fellow Linux beginners!
Next up: Advanced Linux Commands for Power Users!
Would you like any additions or modifications to this post? Let me know!