0% found this document useful (0 votes)
5 views48 pages

learning commands in linux

linux and vs code using c language

Uploaded by

useranjalee
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)
5 views48 pages

learning commands in linux

linux and vs code using c language

Uploaded by

useranjalee
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
You are on page 1/ 48

Lab 1: Learning Basic Linux Commands

OS Used: Ubuntu (24.04 LTS)

1.1. Command Name: ls

Usage : The ls command is used to list all directories and files in the Linux
terminal. When we run the command basically it displays the contents of the
current directory or folder so that users can view the names of file, directories,
and their information. The ls command use the default option to show the files in
alphabetical order but it can be modified also with different options to display
extra information such as permissions, ownership, and size.

Syntax: ls [option] [file/directory]

Commands Used:
Þ ls :- Shows all files and folders in the current directory.
Þ ls -l :- Lists with details (permissions, size, dates, etc.)
Þ ls -a :- Includes hidden files (those starting with .).

Output:
1.2. Command Name: cd

Usage : The 'cd' command allows users to change their current working directory
within the file system.

Syntax: cd [directory]

Commands Used:
Þ cd ~/[directory] :- Go to a specific directory.
Þ cd .. :- Go up one level to the parent directory.
Þ cd :-Go to your home directory).

Output:

1.3. Command Name: grep

Usage : The grep command in Linux is a powerful tool used for searching and
manipulating text patterns within files. Its name is derived from the ed (editor)
command g/re/p (globally search for a regular expression and print matching
lines), which reflects its core functionality.

Syntax: grep [options] pattern [files]

Commands Used:
Þ grep "cute" myfile.txt :- This searches the file “myfile.txt” for lines
containing "cute" and prints those lines.
Þ grep -v "pattern" filename :- This prints out all the lines that do not
matches the pattern in a file “filename”.
Þ grep -c "pattern" filename :- This prints only a count of the lines that
match a pattern.
Þ grep -n "pattern" filename :- Display the matched lines and their line
numbers.
Output:

1.4. Command Name: su

Usage : The su stands for (substitute user), it is a command in Linux that is used
to switch from one user to another user account within the current shell session.
It is useful for quick switching between the users without changing the existing
environment setup.

Syntax: su [username]

Commands Used:
Þ su username :- Used to switch to another user from the terminal. This
switches to user “username” after entering the password for that user.

Output:

1.5. Command Name: sudo

Usage : sudo (Super User DO) command in Linux is generally used as a prefix
for some commands that only superusers are allowed to run. If you prefix any
command with "sudo", it will run that command with elevated privileges or in
other words allow a user with proper permissions to execute a command as
another user, such as the superuser. This is the equivalent of the "run as
administrator" option in Windows. The option of sudo lets us have multiple
administrators.

Syntax: sudo [command]

Commands Used:
Þ sudo -V :- causes sudo to print the version number and exit. If the
invoking user is already root, the -V option will print out a list of the
defaults sudo was compiled with.
Þ sudo -l :- prints out the commands allowed (and forbidden) the user on
the current host.

Output:

1.6. Command Name: pwd

Usage : The 'pwd,' which stands for "print working directory." It prints the path
of the working directory, starting from the root.

Syntax: pwd [OPTIONS]

Commands Used:
Þ pwd -L :- Prints the symbolic path.
Þ pwd -P :- Prints the actual path
Output:

1.7. Command Name: mv

Usage : `mv` stands for "move". The mv command is for renaming and moving
files and directories within a filesystem. Although desktop operating systems
have graphical user interfaces for file operations, calling mv in the terminal,
usually offers a better approach.

Syntax: mv [options(s)] [source_file_name(s)] [Destination_file_name]

Commands Used:
Þ mv oldname.txt newname.txt :- Renames an already existing file.
Þ mv file.txt ~/Downloads/ :- Moves a file to another folder.

Output:
1.8. Command Name: cp

Usage : The cp (copy) command is used for duplicating files and folders quickly.
cp lets you copy items between locations while keeping the original intact. The
cp command requires at least two filenames in its arguments.

Syntax: cp source_file destination

Commands Used:
Þ cp file.txt backup.txt :- This creates a new file ‘backup.txt’ that’s a copy of
‘file.txt’.
Þ cp file1.txt file2.txt ~/Backup/:- This makes copies of the mentioned files
into a folder ‘Backup’.

Output:

1.9. Command Name: rm

Usage : rm stands for remove. rm command is used to remove objects such as


files, directories, symbolic links and so on from the file system. Once you delete
the files then you are not able to recover the contents of files and directories.

Syntax: rm filename

Commands Used:
Þ rm myfile.txt :- This deletes ‘myfile.txt’ with no confirmation and no Trash
— it's gone immediately.

Output:
1.10. Command Name: mkdir

Usage : 'mkdir' stands for "make directory," and it helps you organize your
computer stuff by creating folders with just one command. This command can
create multiple directories at once as well as set the permissions for the
directories. It is important to note that the user executing this command must have
enough permission to create a directory in the parent directory, or he/she may
receive a 'permission denied' error.

Syntax: mkdir [options] [directory_name]

Commands Used:
Þ mkdir directory :- creates a directory named ‘directory’ in the current
location.

Output:

1.11. Command Name: rmdir

Usage : The 'rmdir' command in Linux is specifically designed for removing


empty directories. Unlike the rm command, which can delete both files and
directories, rmdir focuses solely on directories. It ensures whether the directories
are empty or not before deleting it and it will delete only if those are empty. It
helps to prevent data loss by accidentally removing the data contained directories.

Syntax: rmdir [options] [directory]


Commands Used:
Þ rmdir foldername :- This will remove ‘foldername’ only if its empty.

Output:

1.12. Command Name: chmod

Usage : The chmod command is used to change the access mode of a file. The
name is an abbreviation of change mode which states that every file and directory
has a set of permissions that control the permissions like who can read, write or
execute the file. In this the permissions have three categories: read, write, and
execute simultaneously represented by `r`, `w` and `x`. These letters combine
together to form a specific permission for a group of users.
The `chmod` command is used to modify this permission so that it can
grant or restrict access to directories and files. Each permission is represented by
a number:

Permission Value
Read (r) 4
Write (w) 2
Execute (x) 1

You add the values to set combinations.

Syntax: chmod [options] [mode] [File_name]

Commands Used:
Þ chmod 755 myFile.txt :- This will provide full access for owner,
read/execute for others since:
Owner: read + write + execute (7)
Group: read + execute (5)
Others: read + execute (5)
Output:

1.13. Command Name: cat

Usage : The cat command in Linux is used for various file-related operations,
allowing users to view, concatenate, create, copy, merge, and manipulate file
contents.

Syntax: cat [OPTION] [FILE]

Commands Used:
Þ cat myfile.txt :- This prints the entire contents of “myfile.txt” to the
terminal.
Output:

1.14. Command Name: chown

Usage : The chown command, short for "change owner," is a powerful tool that
allows users to change owner of file in Linux. This command is particularly
useful in scenarios where administrators need to grant or revoke access to specific
resources.

Syntax: chown [options] new_owner[:new_group] file(s)

Commands Used:
Þ sudo chown anjalo sample.txt :- This command makes anjalo the new
owner of the file sample.txt
Output:

1.15. Command Name: echo

Usage : The echo command in Linux is a built-in command that allows users to
display lines of text or strings that are passed as arguments. It is commonly used
in shell scripts and batch files to output status text to the screen or a file.

Syntax: echo [option] [string]

Commands Used:
Þ echo "Hello, World" :- echo command prints texts inside the double
quotations.
Output:

1.16. Command Name: wc

Usage : wc stands for word count. It is mainly used for counting purpose. It is
used to find out number of lines, word count, byte and characters count in the
files specified in the file arguments. By default, it displays four-columnar output.
First column shows number of lines present in a file specified, second column
shows number of words present in the file, third column shows number of
characters present in file and fourth column itself is the file name which are given
as argument.

Syntax: wc [OPTION] [FILE]


Commands Used:
Þ wc myfile.txt :- This command is used to count: lines, words, characters
(bytes) in files. It’s ouput means 10 lines 25 words 150 bytes (characters)
in ‘myfile.txt’.

Output:

1.17. Command Name: man

Usage : The "man" command, short for manual, is a powerful tool in the Linux
operating system that allows users to access detailed information about various
commands, utilities, and system calls. The "man" command provides
comprehensive documentation, helping users understand how to use and
configure different elements of the Linux environment.

Syntax: man [option] [command]

Commands Used:
Þ man ls :- This shows the manual page for the ls command.

Output:
1.18. Command Name: history

Usage : The history command in Linux is essential for terminal users, enabling
them to view, search, and manipulate previously executed commands. Mastering
this Linux command allows for efficient commands of commands, automation of
repetitive tasks, and troubleshooting without the need to retype lengthy
commands.

Syntax: history

Commands Used:
Þ history :- history command shows a list of all previously run commands
in our current terminal session (and older ones too, if saved).

Output:

1.19. Command Name: clear

Usage : clear is used to clear the terminal screen. This command first looks for a
terminal type in the environment and after that, it figures out the terminfo
database for how to clear the screen. And this command will ignore any
command-line parameters that may be present. Also, the clear command doesn't
take any argument and it is almost similar to cls command on a number of other
Operating Systems.

Syntax: clear
Commands Used:
Þ clear :- clears the terminal screen.

Output:

1.20. Command Name: touch


Usage : The touch command is a standard command used in the Linux operating
system which is used to create, change and modify the timestamps of a file.
Syntax: touch [options] file_name

Commands Used:
Þ touch notes.txt :- If ‘notes.txt’ doesn't exist, it will be created as an empty
file. If it already exists, its modification time will be updated to the
current time.
Þ touch foldername/myfile.txt :- Creates a file named ‘myfile.txt’ in folder
named ‘foldername’.
Output:

1.21. Command Name: locate


Usage : locate command in Linux is used to find the files by name. By default,
locate command does not check whether the files found in the database still exist
and it never reports files created after the most recent update of the relevant
database.
Syntax: locate [OPTION]... PATTERN...

Commands Used:
Þ locate notes.txt :- Finds the path of file ‘notes.txt’. It shows all matching
paths instantly.

Output:

1.22. Command Name: netstat


Usage : The netstat command is like a special tool in Linux that helps understand
and check things about how a computer connects to the internet. It tells about the
connections your computer is making, the paths it uses to send information, and
even some technical details like how many packets of data are being sent or
received. In simple terms, it's like a window that shows what's happening with
your computer and the internet.
Syntax: netstat [options]

Commands Used:
Þ netstat -t :- Shows TCP connections.
Þ netstat -u :- Shows UDP connections.
Þ netstat -lt :- This command specifically lists the TCP ports that are in a
listening state.
Output:
1.23. Command Name: ss
Usage : 'ss' command stands for "Socket Statistics". It is a potent tool for
inspecting and displaying detailed information about network sockets on a Linux
system. The 'ss' command is an indispensable resource for network
administrators, system administrators, and developers, offering insights into
network connections, routing tables, and more.
Syntax: ss [options]

Commands Used:
Þ ss -t :- Displays TCP sockets.
Þ ss -u :- Displays UDP sockets
Þ ss -s :- Displays summary statistics.
Þ ss -4 :- Displays only IPv4 sockets.
Output:

1.24. Command Name: df


Usage : disk free also known as `df`, provides valuable information on disk space
utilization. The df command displays information about file system disk space
usage on the mounted file system. By default, df command shows disk space in
Kilobytes (KB) and uses the SI unit suffixes (e.g, M for megabytes, G for
gigabytes) for clarity.
Syntax: df [options] [filesystems]
Commands Used:
Þ df :- Shows available and used disk space in blocks, which isn't very
human-friendly.
Þ df -h :- Used for human-readable format. This shows sizes in KB, MB, or
GB.

Output:

1.25. Command Name: du


Usage : The `du` command allows users to analyze and report on disk usage
within directories and files. Whether you're trying to identify space-hogging
directories, manage disk space efficiently, or simply gain insights into storage
consumption, the du command provides valuable information.
Syntax: du [options] [directory/file]
Commands Used:
Þ du Downloads :- Shows how much space each file/subfolder inside
‘Downloads’ is using (in kilobytes by default).
Þ du -h Downloads :- Used for human-readable format. This shows sizes in
KB, MB, or GB.
Þ du -sh Downloads :- Shows only the total size of a folder ‘Downloads’.
Output:

1.26. Command Name: uname


Usage : The term "uname" stands for "Unix Name," and the command itself is
designed to provide you with key details about your Linux system. It's like asking
your computer, "Hey, who are you, and what are you made of?" The answers you
get can help you understand your system's kernel version, operating system,
hardware architecture, and more. This command 'uname' displays the information
about the system.
Syntax: uname [OPTIONs]
Commands Used:
Þ uname -a :- Displays all available information.
Þ uname -s :- Shows the kernel name.
Þ uname -n :- Displays the network (domain) name of the machine.
Þ uname -r :- Shows the kernel release.
Þ uname -v :- Displays the kernel version.
Þ uname -m :- Shows the machine hardware name.
Þ uname -p :- Displays the processor type or "unknown."
Þ uname -i :- Shows the hardware platform or "unknown."
Þ uname -o :- Displays the operating system.

Output:
1.27. Command Name: passwd
Usage : The passwd command in Linux provides a straightforward and effective
way to modify user passwords.
Syntax: passwd [options] [username]
Commands Used:
Þ passwd -h :- Displays help related to the `passwd` command.

Output:

1.28. Command Name: useradd


Usage : useradd is a command in Linux that is used to add user accounts to a
system.
Syntax: sudo useradd [options] [User_name]
Commands Used:
Þ sudo useradd -m newuser :- -m creates a home directory where,
‘newuser’ is the username.
Þ sudo passwd newuser :- Prompts to create a new password.

Output:
1.29. Command Name: userdel
Usage : 'userdel' command is used to delete a user account and related files. The
'userdel' command allows administrators to delete user accounts from the system.
It is a part of the user management tools that also include commands like 'useradd'
and 'usermod'. The 'userdel' command not only removes the user account but also
takes care of associated files, such as the home directory.
Syntax: sudo userdel [options] username
Commands Used:
Þ sudo userdel -f newuser :- Force removal of the user account, including
home directory and mail spool, even if the user is logged in
Output:

1.30. Command Name: apt-get


Usage : apt-get is a command-line tool that helps in handling packages in Linux.
It is used to install, update, upgrade, and remove software packages via the
terminal. Its main task is to retrieve the information and packages from the
authenticated sources for installation, upgrade, and removal of packages along
with their dependencies. Here APT stands for Advanced Packaging Tool. It is a
Debian-based Linux operating system, for example, Ubuntu and Debian itself. It
is an APT (Advance Packaging Tool) system. Which manages packages for
Debian-based Linux distributions.
Syntax: sudo apt-get [options] [command] [package(s)]
Commands Used:
Þ sudo apt-get autoremove :- Removes unused packages.

Output:
1.31. Command Name: apt
Usage : apt provides a high-level Command Line Interface (CLI) for the APT
package management system, offering a user-friendly interface intended for
interactive use. It simplifies common tasks like installation, upgrades, and
removal, with better defaults than more specialized tools like apt-get and apt-
cache.
Syntax: apt [...COMMANDS] [...PACKAGES]
Commands Used:
Þ sudo apt autoremove :- Removes unused packages.

Output:

1.32. Command Name: ping


Usage : The PING (Packet Internet Groper) command is used to check the
network connectivity between the host and server/host. This command takes as
input the IP address or the URL and sends a data packet to the specified address
with the message "PING" and gets a response from the server/host this time is
recorded which is called latency. Fast ping with low latency means a faster
connection.
Syntax: ping [options] host_or_IP_address
Commands Used:
Þ ping google.com :- This sends repeated ICMP packets to Google's server
and tells you; if it's reachable and how fast it responds (in milliseconds).
Output:
1.33. Command Name: find
Usage : The find command in Linux is used to search for files and directories
based on name, type, size, date, or other conditions. It scans the specified
directory and its sub directories to locate files matching the given criteria.
Syntax: find [path] [options] [expression]
Commands Used:
Þ find /home -name "myFile.txt" :- This searches for ‘myFile.txt’ under
/home (and subfolders)

Output:

1.34. Command Name: head


Usage : The head command in Linux is used to display the first few lines (or
bytes) of one or more text files. By default, it outputs the first 10 lines of a file,
making it invaluable for quickly previewing content without opening large files
entirely. It’s widely used in system administration, log analysis, data processing,
and scripting to extract or inspect critical information efficiently.
Syntax: head [options] [file(s)]
Commands Used:
Þ head -n 5 myFile.txt :- Shows the first 5 lines of the file ‘myFile.txt’.
Output:
1.35. Command Name: rename
Usage : It's a tool used in Linux to change the names of lots of files all at once. It
works by following a set of instructions, kind of like a recipe, to rename files in
a specific way.
Syntax: rename [options] expression files
Commands Used:
Þ head -n 5 myFile.txt :- Shows the first 5 lines of the file ‘myFile.txt’.
Output:

1.36. Command Name: tail


Usage : It's a tool used in Linux to change the names of lots of files all at once. It
works by following a set of instructions, kind of like a recipe, to rename files in
a specific way.
Syntax: rename [options] expression files
Commands Used:
Þ tail -n 5 myFile.txt :- Shows the last 5 lines of the file ‘myFile.txt’.
Output:
1.37. Command Name: tac
Usage : tac command in Linux is used to concatenate and print files in reverse.
This command will write each FILE to standard output, the last line first. When
no file is specified then this command will read the standard input.
Syntax: tac [OPTION]... [FILE]...
Commands Used:
Þ tac myFile.txt :- It prints the contents of a file from bottom to top — last
line first.
Output:

1.38. Command Name: comm


Usage : The 'comm' command is used for line-by-line comparison of two sorted
files. It reads two files as input and generates a three-column output by default:
Column 1: Lines unique to the first file.
Column 2: Lines unique to the second file.
Column 3: Lines common to both files.
Syntax: comm file1 file2
Commands Used:
Þ comm file1.txt file2.txt :- Compares two sorted files and shows lines
unique to each and lines common to both.
Output:
1.39. Command Name: cut

Usage : The cut command in linux is a command for cutting out the sections from
each line of files and writing the result to standard output. It can be used to cut
parts of a line by byte position, character, and field. The cut command slices a
line and extracts the text. It is necessary to specify an option with a command
otherwise it gives an error. If more than one file name is provided then data from
each file is not preceded by its file name.

Syntax: cut OPTION... [FILE]..


Commands Used:
Þ cut -c 1-3 filename.txt :- Extracts the first 3 characters from each line.
Output:

1.40. Command Name: sort

Usage : The sort command in Linux is used to sort a file, arranging the records
in a particular order. By default, the sort command sorts file assuming the contents
are ASCII. Using options in the sort command can also be used to sort
numerically.

Syntax: sort [OPTION]... [FILE]...


Commands Used:
Þ sort file.txt :- Sorts the lines of file.txt in alphabetical order (A-Z).
Þ sort -r file.txt :- Sorts the lines of file.txt in reverse order.
Output:

1.41. Command Name: date

Usage : The date command in Linux allows the user to display the current date
and time in a variety of formats and set the system date and time. Being a part of
the core utilities in Linux and Unix-like operating systems, it makes it an essential
command for system configuration and scripting. However, by default, the date
displays the current time in the system's configured timezone. It supports
formatting using the special date format specifiers to display the time exactly the
way you need it.

Syntax: date [OPTION]... [+FORMAT]


Commands Used:
Þ date :- The date command is used to display or set the system date and
time.

Output:
1.42. Command Name: cal

Usage : cal command is a command in Linux which is used to see the calendar
of a specific month or a whole year. By default, entering cal in the terminal shows
the calendar of the current month, with today's date highlighted. This provides a
quick overview of the month at hand.

Syntax: cal [ [ month ] year]


Commands Used:
Þ cal :- Displays a calendar in the terminal.

Output:

1.43. Command Name: time

Usage : 'time' command in Linux is used to execute a command and prints a


summary of real-time, user CPU time and system CPU time spent by executing a
command when it terminates. 'real' time is the time elapsed wall clock time taken
by a command to get executed, while 'user' and 'sys' time are the number of CPU
seconds that command uses in user and kernel mode respectively.

Syntax: time [options] command [arguments]


Commands Used:
Þ cal :- Displays a calendar in the terminal.
Output:

1.44. Command Name: host

Usage : host command in Linux system is used for DNS (Domain Name System)
lookup operations. In simple words, this command is used to find the IP address
of a particular domain name or if you want to find out the domain name of a
particular IP address the host command becomes handy. You can also find more
specific details of a domain by specifying the corresponding option along with
the domain name.

Syntax: host [options] name [server]


Commands Used:
Þ host google.com :- Lookup IP address for ‘google.com’.
Output:
1.45. Command Name: wget

Usage : The wget command in Linux is used to download files from the web via
HTTP, HTTPS, or FTP.

Syntax: wget [options] [URL]

Commands Used:
Þ wget https://example.com/index.html :- This downloads the file named
index.html from the website example.com. The file will be saved in the
current folder. Basically, it fetches a small web page file from the internet
onto your computer.
Output:

1.46. Command Name: id

Usage : The 'id' command in Linux is used to display user and group names along
with their numeric IDs (User ID - UID or Group ID - GID) of the current user or
any specified user on the system. This command is particularly useful for system
administrators and users who need to verify user identities and associated
permissions.

Syntax: id [OPTION]… [USER]

Commands Used:
Þ id username :- This shows the same information but for the user called
‘username’.
Output:

1.47. Command Name: ps

Usage : The `ps` command, which stands for "process status," is like a computer
tool that helps you see what's happening inside your Linux computer. Imagine
your computer is doing several things simultaneously, like running different
programs or apps. These are the processes and the `ps` command lets you take a
quick look at them.

Syntax: ps [options]

Commands Used:
Þ ps :- Shows the processes running in the current shell/session.
Output:

1.48. Command Name: top

Usage : top command is used to show the Linux processes. It provides a dynamic
real-time view of the running system. Usually, this command shows the summary
information of the system and the list of processes or threads which are currently
managed by the Linux Kernel. As soon as you will run this command it will open
an interactive command mode where the top half portion will contain the statistics
of processes and resource usage. And Lower half contains a list of the currently
running processes. Pressing q will simply exit the command mode.

Syntax: top [options]

Commands Used:
Þ top :- Shows a real-time view of a system's processes — like a live task
manager in the terminal.
Output:

1.49. Command Name: kill

Usage : kill command in Linux (located in /bin/kill), is a built-in command which


is used to terminate processes manually. kill command sends a signal to a process
that terminates the process. If the user doesn't specify any signal that is to be sent
along with the kill command, then a default TERM signal is sent that terminates
the process.

Syntax: kill [signal] PID

Commands Used:
Þ kill 1234:- This sends signal 15 (SIGTERM) to process 1234, asking it to
stop politely.
Output:

1.50. Command Name: pkill

Usage : The pkill command is used to kill a process by its name instead of its
PID. It’s like kill, but more user-friendly because you don’t need to find the
process ID (PID).

Syntax: pkill [options] pattern

Commands Used:
Þ pkill firefox :- This will stop all processes with the name ‘firefox’.
Þ pkill -u student firefox :- This will kill ‘firefox’ processes started by user
‘student’.

Output:

1.51. Command Name: killall

Usage : The primary contrast between the kill and kill all commands is that the
"kill" ends process cycles dependent on Process ID number (PID), while the kill
orders end running cycles dependent on their names and different attributes.
Normal users can end/kill their cycles(processes), but not those that have a place
with different users, while the root client can end all cycles.

Syntax: killall [options] process_name


Commands Used:
Þ killall firefox :- This stops all Firefox processes currently running.
Þ killall -u student firefox :- Stops all ‘firefox’ processes that were started
by the user named student.
Output:

1.52. Command Name: bg

Usage : In Linux, the bg command is a useful tool that helps to manage and move
processes between the foreground and background. It's especially helpful when
multitasking in the terminal by placing a process in the background, enabling
continuing using the terminal for other commands while the process runs quietly
in the background.

Syntax: bg [job_spec]

Commands Used:
Þ sleep 30 :- This starts a command that waits 30 seconds.
Þ bg :- Resumes it in the background, so the terminal stays free.
Output:

1.53. Command Name: fg

Usage : The fg command in Linux is used to bring a background job into the
foreground. It allows you to resume a suspended job or a background process
directly in the terminal window, so you can interact with it.
Syntax: fg [job_spec]

Commands Used:
Þ sleep 100 :- This starts a command that waits 100 seconds.
Þ bg :- Resumes it in the background, so the terminal stays free.
Þ fg :- Brought it back to the foreground so you can interact or stop it.
Output:

1.54. Command Name: tar

Usage : The tar command is used to archive (combine) and compress files or
directories. It stands for “tape archive” and is commonly used to create .tar or
.tar.gz files.

Syntax: tar [options] [archive_name.tar] [file(s)/directory]

Commands Used:
Þ tar -cvf myfolder.tar myfolder/ :- Creates ‘myfolder.tar’ containing the
contents of ‘myfolder’.

Output:
1.55. Command Name: gzip

Usage : The gzip command is used to compress files in Linux. It reduces the
file size using the .gz (GZIP) compression format. It compresses a single file
(makes it smaller) and replaces the original file with a .gz version which can be
used with gunzip to extract the file later.

Syntax: gzip [options] filename

Commands Used:
Þ gzip notes.txt :- This compresses notes.txt and creates notes.txt.gz. The
original notes.txt is removed by default.
Þ gunzip notes.txt.gz :- This restores notes.txt and deletes the .gz file.

Output:

1.56. Command Name: alias

Usage : In Linux, an alias is a user-defined shorthand for a longer command or


sequence of commands. These aliases can be created and customized according
to user preferences, making the command-line interface more user-friendly. The
alias command instructs the shell to replace one string with another string while
executing the commands. When we often have to use a single big command
multiple times, in those cases, we create something called an alias for that
command. Alias is like a shortcut command, which will have the same
functionality as if we were writing the whole command.

Syntax: alias shortname='longer command'

Commands Used:
Þ alias ll='ls -la' :- This creates a shortcut for ‘ls -la’. Now typing ‘ll’ will
run ‘ls -la’.
Output:

1.57. Command Name: who

Usage : The who command is a simple and effective way to display information
about currently logged-in users. By typing who in the terminal, you will receive
a list of usernames, terminal IDs, login times, and originating IP addresses if
applicable. The who command is used to get information about currently
logged-in users on the system. The who command is used to find out the
following information :
Time of last system boot
Current run level of the system
List of logged-in users and more.

Syntax: who [options] [filename]


Commands Used:
Þ alias ll='ls -la' :- This creates a shortcut for ‘ls -la’. Now typing ‘ll’ will
run ‘ls -la’.
Output:
1.58. Command Name: whoami

Usage : The whoami command shows the current logged-in username — that
is, who you are in the system.

Syntax: whoami

Commands Used:
Þ whoami :- It shows the username of the person currently logged in to the
terminal.

Output:

1.59. Command Name: w

Usage : The 'w' command in Linux gives us important information about who is
currently using the computer, how much the computer is being used, and what
programs are running. It's a handy tool for people who take care of computer
systems, as it helps them keep an eye on what users are doing, how much of the
computer's power is being used, and how to make everything run smoothly.

Syntax: w [options] [user]

Commands Used:
Þ w :- It displays usernames, login times, idle time, and current commands. It
also shows system uptime and load average.

Output:
1.60. Command Name: uptime

Usage : It is used to find out how long the system is active (running). This
command returns set of values that involve, the current time, and the amount of
time system is in running state, number of users currently logged into, and the
load time for the past 1, 5 and 15 minutes respectively.

Syntax: uptime

Commands Used:
Þ w :- It shows how long your computer (Linux system) has been running,
how many people are logged in, and how busy the system is.

Output:

1.61. Command Name: free

Usage : The free command is used to display the amount of free and used
memory (RAM and swap) on your system. It shows how much memory is used,
free, shared, cached, and available and helps monitor system performance.

Syntax: free

Commands Used:
Þ free :- It shows how much memory (RAM and swap) your Linux system is
using and how much is free.

Output:
1.62. Command Name: xargs

Usage : The xargs command is used to build and execute command lines from
standard input. In simpler words, it takes output from one command and uses it
as arguments for another command. It converts input from a pipe or file into
arguments for a command. It’s useful when commands don’t accept input
directly from pipes.It helps run commands on many files or items efficiently.

Syntax: command1 | xargs command2

Commands Used:
Þ echo "file1.txt file2.txt file3.txt" | xargs -n 1 echo :- Prints each file name
on its own line.
Þ echo "file1.txt file2.txt" | xargs ls -l :- Runs ls -l on the two files and
shows detailed info.

Output:

1.63. Command Name: crontab

Usage : The crontab command is used to schedule tasks (commands or scripts)


to run automatically at specified times or intervals. These scheduled tasks are
called cron jobs.It lets you automate repetitive tasks like backups, updates, or
running scripts and runs commands at specific times — every minute, hour, day,
week, month, etc.

Syntax: crontab [options]

Commands Used:
Þ crontab -e :- Opens your crontab file in a text editor where you can add
scheduled tasks.
Output:

1.64. Command Name: env

Usage : The env command shows the environment variables for your current
shell session. Environment variables are settings that affect how processes run,
like your PATH, user info, and more. It displays all environment variables and
their values. It can be used to run a command with a modified environment.

Syntax: env

Commands Used:
Þ env | grep anjalirai :- Runs env to list all environment variables and pipes
(|) that list into grep USER to filter and show only variables containing
"anjalirai".

Output:
1.65. Command Name: printenv

Usage : The printenv command displays environment variables in your current


shell. It’s similar to env but often used just to print variables. It shows all
environment variables if run without arguments and it also shows the value of a
specific environment variable if you provide its name.

Syntax: printenv

Commands Used:
Þ printenv HOME :- Shows the current user's home directory.

Output:

1.66. Command Name: mount

Usage : The mount command in Linux is a powerful tool used to attach file
systems to the directory tree, making them accessible to the operating system and
users. In simpler terms, it allows you to connect storage devices (like USB drives,
hard disks, or network shares) to specific directories (called mount points) so you
can access the files stored on them.

Syntax: sudo mount [options] <device> <mount_point>

Commands Used:
Þ sudo mkdir /mnt/mydisk :- Creates a directory to mount onto.
Þ dd if=/dev/zero of=disk.img bs=1M count=10:- Create a disk image file
(a fake "disk").
Þ mkfs.ext4 disk.img:- Formats it with a filesystem.
Þ sudo mount -o loop disk.img /mnt/mydisk :- Mounts the image file using
a loop device.
Þ ls /mnt/mydisk :- Access the mounted "disk".
Þ sudo umount /mnt/mydisk :- When done, unmount.
Output:

1.67. Command Name: umount

Usage : To unmount mounted file systems from their mount points, use the
umount command. Before physically removing a storage device or making
configuration changes, it is essential to unmount the file system. It is a vital
instrument for securely disconnecting network shares or USB drives, among
other types of storage, from the Linux file system. For the purpose of preventing
data loss or corruption, the command makes sure each of the current file
operations has concluded. This command is typically utilized by users to free up
resources and allow the removal or upkeep of devices.

Syntax: umount [OPTIONS] [TARGET]

Commands Used:
Þ mkdir ~/folder1 :- Creates a folder.
Þ echo "hello" > ~/folder1/hello.txt :- Adds a file inside folder1.
Þ sudo mount --bind ~/folder1 ~/folder2 :- Formats it with a filesystem.
Þ sudo mount -o loop disk.img /mnt/mydisk :- Mounts folder1 into folder2.
Þ ls ~/folder2 :- Checks folder2.
Þ sudo umount ~/folder2 :- Unmounts folder2.
Output:

1.68. Command Name: journalctl

Usage : The `journalctl` command is part of the systemd suite of utilities and is
used to query and display log messages from the systemd journal. The systemd
journal is a centralized logging system that collects and stores log data from
various sources, including system services, kernel events, and user applications.
The journalctl command provides a user-friendly interface to access and retrieve
log information, allowing users to effectively monitor system activity and
diagnose issues.

Syntax: journalctl [options] [unit]

Commands Used:
Þ journalctl -n 5:- Shows the last 5 log entries from the system journal
(recent system messages).
Output:
1.69. Command Name: lsblk

Usage : The lsblk (list block devices) command shows all storage devices
attached to your system — like hard drives, USB drives, and partitions. It lists
storage devices (disks, partitions, etc.) and helps identify device names (like
/dev/sda, /dev/sdb1) but it does not show RAM or CD-ROMs unless specified.

Syntax: lsblk

Commands Used:
Þ lsblk :- It lists all block storage devices on your system — like hard
drives, SSDs, USB drives, and their partitions.

Output:

1.70. Command Name: nano

Usage : The nano command opens a simple text editor in the terminal. It lets you
create or edit text files easily without complex commands.It opens a text editor
in the terminal window. It allows you to write or modify text files. It shows
helpful shortcuts at the bottom (like saving and exiting).

Syntax: nano filename

Commands Used:
Þ nano Notes.txt :- It opens the file named Notes.txt in the nano text editor
inside the terminal. If Notes.txt exists, you can edit its content. If it
doesn't exist, nano will create a new empty file called Notes.txt for you to
write in.
Output:

1.71. Command Name: vim

Usage : vim is a powerful text editor used in the terminal. It’s more advanced
than nano and widely used by programmers and sysadmins. It opens a text file
for editing in the terminal. It has two main modes:
Normal mode (for navigation and commands)
Insert mode (for typing text)

Syntax: vim filename

Commands Used:
Þ vim Notes.txt :- It opens the file named Notes.txt in the vim text editor
inside the terminal. If Notes.txt exists, you can view and edit it. If it
doesn't exist, vim creates a new empty file named Notes.txt for you to
edit.
Output:
1.72. Command Name: less

Usage : At its core, the 'less' command operates as a powerful pager program,
optimized for quick and resource-efficient viewing of text data. 'less' provides a
pragmatic solution for exploring and searching text without the overhead of file
editors like vi or nano.Insert mode (for typing text)

Syntax: less [options] filename

Commands Used:
Þ head -n 10 /var/log/syslog | less :- It shows you the top 10 lines of the system log in
a scrollable viewer, so you can easily read or exit.

Output:

1.73. Command Name: tee

Usage : tee command reads the standard input and writes it to both the standard
output and one or more files. The command is named after the T-splitter used in
plumbing. It basically breaks the output of a program so that it can be both
displayed and saved in a file. It does both the tasks simultaneously, copies the
result into the specified files or variables and also display the result.

Syntax: command | tee filename

Commands Used:
Þ ls -l | tee files.txt :- Lists files in long format, showing the output on the
screen and saving a copy to the file files.txt at the same time.
Output:

1.74. Command Name: scp

Usage : scp (secure copy) is used to copy files between computers securely over
a network using SSH. It copies files or directories from your computer to a remote
machine, or vice versa. It encrypts data during transfer for security.

Syntax: scp localfile username@remote_host:/remote/directory/

Commands Used:
Þ scp test.txt user@example.com:/home/user/ :- It securely copies the
file ‘test.txt’ from your local computer to the directory /home/user/ on the
remote computer identified by example.com, logging in as the user named
‘user’.
Output:

1.75. Command Name: rsync

Usage : The rsync command is used to efficiently copy and synchronize files and
directories between locations, either on the same machine or over a network. It
only transfers the differences between source and destination, which makes it
faster than a simple copy for repeated transfers.
Syntax: rsync [options] source destination

Commands Used:
Þ rsync myFile.txt /home/anjalirai/Documents/ :- This copies
‘myFile.txt’ to the backup folder ‘Documents’.
Output:

1.76. Command Name: ssh

Usage : The ssh command lets you securely connect to a remote computer over
a network.

Syntax: ssh [options] user@hostname

Commands Used:
Þ ssh [options] user@hostname :- This opens a terminal session on the
remote machine where you can run commands just like you’re sitting in
front of it.
Output:

You might also like