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

Essential Linux Commands Guide

The document provides an extensive list of basic Linux commands categorized into sections such as file commands, search commands, process-related commands, system management, disk management, network commands, hardware info commands, and user management commands. Each command is accompanied by a brief description of its function, aimed at helping users explore the Linux operating system. The document serves as a practical guide for users to familiarize themselves with essential Linux commands and their applications.

Uploaded by

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

Essential Linux Commands Guide

The document provides an extensive list of basic Linux commands categorized into sections such as file commands, search commands, process-related commands, system management, disk management, network commands, hardware info commands, and user management commands. Each command is accompanied by a brief description of its function, aimed at helping users explore the Linux operating system. The document serves as a practical guide for users to familiarize themselves with essential Linux commands and their applications.

Uploaded by

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

BSE302P – OPERATING SYSTEMS LAB

INTRODUCTION TO BASIC LINUX COMMANDS


Exercise #1 9/12/2025

Aim: To explore LINUX operating system and understand basic commands

Basic File Commands

Command Description

mkdir [directory_name] Create a new directory.

rm [file_name] Remove a file.

rm -r [directory_name] Remove a directory recursively.

Recursively remove a directory without requiring


rm -rf [directory_name]
confirmation.

cp [source_file] Copy the contents of one file to another file using


[destination_file] the cp command.

cp -r [source_directory]
Recursively copy a directory to a second directory.
[destination_directory]

mv [source_file]
Move or rename files or directories.
[destination_file]

ln -s [path]/[file_name]
Create a symbolic link to a file.
[link_name]

touch [file_name] Create a new file using touch.

cat [file_name] Show the contents of a file.

cat [source_file] >> Append file contents to another file.


[destination_file]
head [file_name] Show the first ten lines of a file.

tail [file_name] Show the last ten lines of a file with the tail command.

more [file_name] Display contents of a file page by page.

Show the contents of a file with navigation using


less [file_name]
the less command.

nano [file_name] Open or create a file using the nano text editor.

vi [file_name]
Open or create a file using the Vi/Vim text editor.
vim [file_name]

gpg -c [file_name] Encrypt a file.

gpg [file_name].gpg Decrypt an encrypted .gpg file.

Show the number of words, lines, and bytes in a file


wc -w [file_name]
using wc.

List the number of lines/words/characters in each file


ls | xargs wc
in a directory with the xargs command.

Cut a section of a file and print the result to standard


cut -d [delimiter] [file_name]
output.

Cut a section of piped data and print the result to


[data] | cut -d [delimiter]
standard output.

shred -u [file_name] Overwrite a file to prevent its recovery, then delete it.

diff [first_file] [second_file] Compare two files and display differences.

source [file_name] Read and execute the file content in the current shell.

[command] | tee [file_name] Store the command output in a file and skip the
>/dev/null terminal output.
ls List files and directories in the current directory.

List all files and directories in the current directory


ls -a
(shows hidden files).

ls -l List files and directories in long format.

pwd Show the directory you are currently working in.

cd
Change directory to $HOME.
cd ~

cd .. Move up one directory level.

cd - Change to the previous directory.

cd [directory_path] Change location to a specified directory.

dirs Show current directory stack.

Assign read, write, and execute file permission to


chmod 777 [file_name]
everyone (rwxrwxrwx).

Give read, write, and execute permission to owner, and


chmod 755 [file_name] read and execute permission to group and others
(rwxr-xr-x).

Assign full permission to the owner, and read and write


chmod 766 [file_name]
permission to the group and others (rwxrw-rw-).

chown [user_name]
Change the ownership of a file with chown command.
[file_name]

chown
[user_name]:[group_na Change the owner and group ownership of a file.
me] [file_name]
Search Commands

Command Description

find [path] -name Find files and directories that match the specified
[search_pattern] pattern in a specified location.

See files and directories larger than a specified size in a


find [path] -size [+100M]
directory.

grep [search_pattern]
Search for a specific pattern in a file with grep.
[file_name]

grep -r [search_pattern]
Recursively search for a pattern in a directory.
[directory_name]

Locate all files and directories related to a particular


locate [name]
name.

Search the command path in the $PATH environment


which [command]
variable.

Use the whereis command to find the source, binary,


whereis [command]
and manual page for a command.

awk '[search_pattern] {print Print all lines matching a pattern in a file. See also
$0}' [file_name] the gawk command, the GNU version of awk.

sed 's/[old_text]/[new_text]/'
Find and replace text in a specified file.
[file_name]

Process Related Commands

Command Description

ps List active processes.

pstree Show processes in a tree-like diagram.


pmap Display a memory usage map of processes.

top See all running processes.

htop Interactive and colorful process viewer.

kill [process_id] Terminate a Linux process under a given ID.

pkill
Terminate a process under a specific name.
[process_name]

killall [label] Terminate all processes with a given label.

prgrep [keyword] List processes based on the provided keyword.

pidof
Show the PID of a process.
[process_name]

bg List and resume stopped jobs in the background.

fg Bring the most recently suspended job to the foreground.

fg [job] Bring a particular job to the foreground.

lsof List files opened by running processes with lsof command.

trap "[commands]" Catch a system error signal in a shell script. Executes provided
[signal] commands when the signal is caught.

Pause the terminal or a Bash script until a running process is


wait
completed.

nohup [command]
Run a Linux process in the background.
&

System Management
Command Description

uname -r Show system information via uname command.

uname -a See kernel release information.

uptime Display system uptime, including the load average.

hostname View system hostname.

hostname -i Show the IP address of the system.

last reboot List system reboot history.

date See current time and date.

timedatectl Query and change the system clock.

cal Show current calendar (month and day).

w List logged-in users.

whoami See which user you are using.

finger [user_name] Show information about a particular user.

ulimit [flags] [limit] View or limit system resource amounts.

shutdown [hh:mm] Schedule a system shutdown.

shutdown now Shut down the system immediately.

modprobe [module_name] Add a new kernel module.

dmesg Show bootup messages.


Disk Management

Command Description

df -h Check free and used space on mounted systems.

df -i Show free inodes on mounted file systems.

Display disk partitions, sizes, and types with the


fdisk -l
command.

du -ah See disk usage for all files and directories.

du -sh Show disk usage of the current directory.

mount Show currently mounted file systems.

findmnt Display target mount point for all file systems.

mount [device_path]
Mount a device.
[mount_point]

Network Commands

Description Command

ip addr show List IP addresses and network interfaces.

ip address add [IP_address] Assign an IP address to interface eth0.

ifconfig Display IP addresses of all network interfaces.

ping [remote_host] Ping remote host.

netstat -pnltu See active (listening) ports with the netstat command.
netstat -tuln Show TCP and UDP ports and their programs.

whois [domain_name] Display more information about a domain.

Show DNS information about a domain using the dig


dig [domain_name]
command.

dig -x [domain_name] Do a reverse DNS lookup on the domain.

dig -x [IP_address] Do a reverse DNS lookup of an IP address.

host [domain_name] Perform an IP lookup for a domain.

hostname -I Show the local IP address.

nslookup [domain_name] Receive information about an internet domain.

Hardware Info Commands

Command Description

lscpu See CPU information.

lsblk See information about block devices.

Show PCI devices (graphics card, network card, etc.) in a


lspci -tv
tree-like diagram.

lsusb -tv Display USB devices in a tree-like diagram.

lshw List hardware configuration information.


cat /proc/cpuinfo Show detailed CPU information.

cat /proc/meminfo View detailed system memory information.

cat /proc/mounts See mounted file systems.

free -h Display free and used memory.

sudo dmidecode Show hardware information from the BIOS.

hdparm -i
Display disk data information.
/dev/[device_name]

hdparm -tT
Conduct a read speed test on the device/disk.
/dev/[device_name]

badblocks -s
Test for unreadable blocks on the device/disk.
/dev/[device_name]

fsck /dev/[device_name] Run a disk check on an unmounted disk or partition.

User Management Commands

Command Description

id See details about the active users.

last Show the last system logins.

Display who is currently logged into the system with


who
the who command.

w Show which users are logged in and their activity with


the w command.
finger [user_name] Show user information.

sudo useradd [user_name] Create a new user account.

Create a new user account through the adduser


sudo adduser [user_name]
command interface.

sudo userdel [user_name] Delete a user account.

sudo usermod -aG


Modify user information (add a user to a group).
[group_name] [user_name]

passwd Change the current user's password or another user's


sudo passwd [user_name] password with the passwd command.

sudo groupadd [group_name] Add a new group.

sudo groupdel [group_name] Delete a group.

sudo groupmod -n
Modify a user group (change group name).
[new_name] [old_name]

Temporarily elevate user privileges to superuser or root


sudo [command]
using the sudo command.

su - [user_name] Switch the user account or become a superuser.

chgrp [group_name]
Change file or directory group.
[file/directory]

You might also like