0% found this document useful (0 votes)
4 views3 pages

Basic Linux CMD

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

Basic Linux CMD

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Part 1: Navigation and File Management

Navigate the file system

pwd – Show the current directory.


cd – Change directories.
Example: cd /var/log
ls – List files and directories.
Options: ls -l, ls -a.

Manage files and directories

mkdir – Create a directory.


Example: mkdir myfolder
touch – Create an empty file.
Example: touch file1.txt
cp – Copy files/directories.
Example: cp file1.txt backup_file1.txt
mv – Move/rename files.
Example: mv file1.txt newname.txt
rm – Delete files.
Example: rm newname.txt

View file contents

cat – View the entire file.


less – View file one screen at a time.
head and tail – View the first/last lines of a file.
Exercise:
Navigate to /tmp and create a directory named practice.
Create a file example.txt inside practice.
Copy example.txt to backup_example.txt.
Delete the example.txt file.

-----------------------------------------
Part 2: User and Permission Management
Commands:

User Management

whoami – Show the current user.


id – Display user ID and groups.
passwd – Change user password.

Permissions

ls -l – View file permissions.


chmod – Change file permissions.
Example: chmod 755 script.sh
chown – Change file ownership.
Example: chown user:group file.txt
Exercise:
Check your current username using whoami.
Create a file and change its permissions to make it
executable by everyone.
-----------------------------------------------
Part 3: Process Control
Commands:

ps – View running processes.


Example: ps aux
top or htop – Monitor system processes in real-time.
kill – Stop a process.
Example: kill <PID> (Get PID from ps or top).
Exercise:
Run a command (e.g., sleep 300) in the background
using &.
Identify the process ID using ps and terminate it with
kill.

----------------------------------------------------------
Part 4: System Monitoring

df -h – View disk usage.


du -sh <directory> – View directory size.
free -h – View memory usage.
uptime – Check how long the system has been running.
Exercise:
Check how much disk space is available on the system.
Find the size of the /var/log directory.
Monitor memory usage with free.

You might also like