Contact Us
Email: info@mohitdesigns.com
Mobile: +91-9718991639
Contact Us
Email: info@mohitdesigns.com
Mobile: +91-9718991639
If you’re diving into the world of Linux, mastering a few key commands will set you up for success. While Linux might seem complex at first, these commands make daily tasks fast and efficient. Whether you’re a beginner or a seasoned user, this guide will cover essential Linux commands to streamline your workflow. So, let’s explore these commands with practical examples to get you comfortable with Linux quickly!
The pwd
command displays the current working directory path, useful for knowing exactly where you are within the file system.
pwd
# Example Output: /home/user/Documents
The ls
command shows the files and directories in your current location. To see hidden files, use the -a
option.
ls
# Lists all files and directories
ls -a
# Lists hidden files too
Use cd
to navigate between directories. If you want to move up a directory, use cd ..
.
cd /home/user/Documents
cd .. # Moves up one directory
The mkdir
command creates a new directory. Add -p
to create parent directories if they don’t exist.
mkdir project
mkdir -p project/subfolder
The rmdir
command deletes an empty directory. If there are files inside, use rm -r
instead.
rmdir project/subfolder
rm -r project # Removes a directory with files
Create an empty file with touch
. This is great for setting up placeholder files.
touch newfile.txt
Copy files with cp
. Use -r
for directories to include all contents.
cp file.txt /destination/
cp -r folder /destination/
The mv
command moves files and directories and can also rename them.
mv oldfile.txt newfile.txt # Renames file
mv file.txt /destination/ # Moves file
Delete files with rm
, adding -r
to remove directories.
rm file.txt
rm -r folder
Use cat
to display file content. It’s quick for short files or to combine files.
cat file.txt
cat file1.txt file2.txt > combined.txt
The nano
command opens a simple editor, great for quick text edits.
nano file.txt
The find
command locates files. Add filters like -name
to search by name.
find /home/user -name "*.txt"
grep
lets you search for text within files, handy for quickly finding content.
grep "search_term" file.txt
grep -r "search_term" /path/to/search
Use chmod
to modify permissions, using symbolic or numeric representations.
chmod 755 script.sh
chmod u+x script.sh # Adds execute permission for the owner
This command changes the ownership of files or directories.
chown user:group file.txt
echo
outputs text or appends it to a file.
echo "Hello, Linux!" > file.txt
The df
command shows disk space usage for mounted filesystems.
df -h
du
displays space used by files and directories. Use -h
for readability.
du -h /path/to/directory
Use tar
to compress and archive files. Add -z
to create a .tar.gz
file.
tar -czvf archive.tar.gz /path/to/files
Unzip compressed .zip
files with this simple command.
unzip archive.zip
ps
lists currently running processes, useful for troubleshooting.
ps aux
kill
lets you end processes by ID. Use ps
to find the process ID.
kill 1234
top
shows active processes in real-time, including CPU and memory usage.
top
Use wget
to download files from the web.
wget http://example.com/file.zip
The curl
command fetches data from URLs, useful for API calls.
curl http://example.com
alias
lets you create command shortcuts.
alias ll='ls -la'
This command shows previously entered commands, perfect for recalling past actions.
history
clear
removes the clutter by clearing the terminal.
clear
Quickly restart your Linux system with this command.
reboot
The shutdown
command shuts down or restarts your system with scheduling options.
shutdown now # Immediate shutdown
shutdown -r +5 # Restarts in 5 minutes
With these essential Linux commands, you’re now equipped to handle most tasks confidently. Try incorporating these commands into your routine, and soon you’ll feel like a Linux pro! Linux commands are powerful tools for navigating and managing your system. As you explore these further, you’ll see just how efficient they can make your workday.
If you’re interested in choosing the right distribution, check out our guide on the best Linux distros to find one that fits your needs and preferences.
For more detailed explanations of these and other Linux commands, explainshell.com is a fantastic resource that breaks down commands step-by-step.