When you first log into a Linux server, you're greeted by the command line. It can be intimidating, but it's incredibly powerful. This guide covers the essential commands every beginner should know.
Navigation
pwd - Where Am I?
Print Working Directory shows your current location:
pwd
Output might be: /home/username
ls - What's Here?
List files and directories:
ls
List with details:
ls -la
cd - Change Directory
Navigate to a directory:
cd /home/username/documents
Go back to home:
cd ~
File Operations
mkdir - Make Directory
Create a new directory:
mkdir myproject
touch - Create File
Create an empty file:
touch readme.txt
cp - Copy
Copy a file:
cp file.txt backup.txt
Copy a directory:
cp -r myfolder backupfolder
mv - Move/Rename
Move or rename files:
mv oldname.txt newname.txt
rm - Remove
Delete a file:
rm unwanted.txt
Delete a directory:
rm -rf myfolder
Viewing Files
cat - View Entire File
cat myfile.txt
head/tail - View Part of File
First 10 lines:
head myfile.txt
Last 10 lines:
tail myfile.txt
less - Browse File
less myfile.txt
Press q to quit, / to search
System Info
whoami - Current User
whoami
uname - System Info
uname -a
df - Disk Space
df -h
free - Memory Usage
free -h
top - Running Processes
top
Press q to quit
Pipes and Redirection
| - Pipe
Send output to another command:
ls -la | grep txt
> - Redirect Output
Save output to file:
echo "hello" > file.txt
>> - Append
Append to file:
echo "more" >> file.txt
Help
--help
ls --help
man - Manual Pages
man ls
which - Find Command
which python
These commands form the foundation of Linux. Practice them and you'll be navigating the command line with confidence in no time!