Explain Navigation Commands
Linux navigation commands are used to view, create, remove, list, and move between directories through the terminal. The main commands are pwd, cd, mkdir, rmdir, ls, and tree.
Common Syntax
$ pwd
$ cd /home/user/Pictures
$ mkdir mydirectory
$ rmdir mydirectory
$ ls -al
$ tree Documents
Quick Revision
| Command | Function |
|---|---|
| pwd | Shows the current directory |
| cd | Changes the current directory |
| mkdir | Creates a directory |
| rmdir | Removes an empty directory |
| ls | Lists files and directories |
| tree | Displays directory hierarchy |
Explain File Management Commands
File management commands in Linux are used to create, view, copy, move, rename, and delete files and directories. The main commands are cat, rm, cp, mv, and touch.
Examples
cat > filename
cat file1 file2 > file3
rm sample.txt
cp original_file new_file
mv test.txt newtest.txt
touch demo.txt
Explain File Permissions and Ownership Commands
Linux is a multi-user operating system, so file permissions and ownership are used to protect files and directories from unauthorized access. Linux provides two levels of authorization: Ownership and Permissions.
Ownership
Permissions
| Permission | Symbol | Value | Meaning |
|---|---|---|---|
| Read | r | 4 | Allows reading the file |
| Write | w | 2 | Allows modifying the file |
| Execute | x | 1 | Allows executing the file |
Important Commands
chmod 764 sample.txt
chmod u+x file.txt
chmod g-w file.txt
chown faizan sample.txt
chown faizan:students sample.txt
chgrp students sample.txt
umask
umask -s
umask 0022
Explain Common System Commands
Common system commands in Linux are used to perform basic system operations such as checking logged-in users, displaying information, getting help, viewing date and time, and clearing the terminal.
Examples
who
whoami
man ls
echo "Hello, World!"
date +%d/%m/%Y
clear
| Command | Purpose |
|---|---|
| who | Shows currently logged-in users |
| whoami | Shows the current user's name |
| man | Displays the manual/help for commands |
| echo | Displays text or command results |
| date | Displays or sets date and time |
| clear | Clears the terminal screen |
Explain Text Processing Commands
Text processing commands in Linux are used to view, extract, sort, compare, transform, filter, count, and redirect text data stored in files.
Examples
head sample.txt
tail -f sample.txt
cut -d "," -f 2 file.txt
sort -r file.txt
cmp -s file1 file2
tr 'a-z' 'A-Z'
uniq -c file.txt
wc -l file.txt
ls | tee output.txt
Explain Process Control Commands
A process is an instance of a program currently running in the system. Process control commands are used to view, control, move, and terminate running processes in Linux.
Examples
ps -e
ps -f
ps ux
bg %1
fg %1
top
kill 1234
kill -9 1234
nice -n 10 firefox
| Command | Function |
|---|---|
| ps | Displays process status |
| bg | Resumes a process in the background |
| fg | Brings a process to the foreground |
| top | Displays running processes in real time |
| kill | Terminates a process |
| nice | Sets the priority of a process |
Explain Job Scheduling Commands
Job scheduling in Linux is used to automatically execute commands or tasks at a specified time or under specified conditions.
Examples
at 10:30 PM
at now + 1 hour
batch
cron
crontab -e
crontab -l
crontab -r
0 8 * * * /home/user/script.sh
| Command | Purpose |
|---|---|
| at | Schedules a one-time job at a specified time |
| batch | Runs a job when system load is low |
| cron | Service for recurring / periodic jobs |
| crontab | Creates and manages cron schedules |