Professional Documents
Culture Documents
Examples
Examples
Examples
LINUX INSTALLATION
Welcome to our quick guide on Managing CLI Commands! In this brief tutorial, we'll navigate
the essentials of Command Line Interface (CLI) management. Let's dive in!
Command Line Interface (CLI) is a powerful and efficient tool for interacting with a computer
system through text commands.
Working with Ubuntu on a Virtual Box, terminal, as the command-line interface, becomes your
gateway to efficiently manage your Ubuntu environment.
1. cd
cd [directory]
Examples:
2. ls
The ls command is used in Unix and Unix-like operating systems (including Linux) to list the
files and directories in the current directory. It provides a simple way to view the contents of a
directory.
Examples:
3. whoami
The whoami command is a Unix and Unix-like operating system command that prints
the username associated with the current effective user ID. When you run the whoami
command, it simply outputs the username of the user who is currently logged in or executing
the command.
Whoami
Examples:
4. who
The who command is used in Unix and Unix-like operating systems to display
information about users who are currently logged into the system. It provides details such as
usernames, terminal names, login times, and originating IP addresses (if applicable).
who
Examples:
5. w
The w command is used in Unix and Unix-like operating systems to display information about
the users who are currently logged in and their activities. The w command provides details such as
the username, terminal, remote host (if applicable), login time, idle time, JCPU (total CPU time used
by all processes attached to the terminal), and more.
Examples:
6. pwd
The pwd command stands for "print working directory." It is used in Unix and Unix-like
operating systems to display the current working directory, which is the directory that the user is
currently in within the file system.
Pwd
Examples:
7. ip addr
The ip addr command is used in Unix-like operating systems, including Linux, to display
information about network interfaces and their associated IP addresses. It provides detailed
information about the current network configuration of a system.
ip addr
Examples:
8. nmcli
The nmcli command is a command-line client for NetworkManager, a Linux utility for
managing network connections. The nmcli device status command is used to
Examples:
9. last
The last command is used in Unix and Unix-like operating systems to display information
about previously logged-in users and system reboots. It shows a list of login sessions, including the
username, terminal, IP address (if available), login and logout times, and other relevant information.
Last
Examples:
10. lastb
11. top
The top command is used in Unix and Unix-like operating systems to display real-time
information about system performance, processes, and resource utilization.
top
Examples:
12. dmidecode
The dmidecode command is a Linux and Unix command-line tool that provides detailed
information about a computer's hardware components, as retrieved from the system's DMI (Desktop
Management Interface) table. The DMI table contains information about the system's BIOS,
motherboard, memory, CPU, and other hardware components.
sudo dmidecode
Examples:
13. netstat
The netstat command is used to display various network-related information in Unix and
Unix-like operating systems, including Linux. It provides details about network connections, routing
tables, interface statistics, masquerade connections, and multicast memberships. netstat can be a
powerful tool for network troubleshooting and monitoring.
netstat [options]
Examples:
14. df
The df command is used in Unix and Unix-like operating systems, including Linux, to display
information about disk space usage on file systems. It shows the amount of disk space used,
available, and total size for each mounted file system.
Examples:
15. du
The du command, which stands for disk usage, is used in Unix and Unix-like operating
systems to estimate the space used by a directory and its subdirectories. It's a useful tool for
analyzing disk space usage on a file system.
Examples:
16. shutdown -r
The shutdown command is used to shut down or reboot a Unix or Unix-like system. It allows
you to initiate a system shutdown, bringing the system to a state where it can be safely powered off
or restarted.
Examples:
17. hostname
The hostname command is used to show or set the system's hostname on Unix and Unix-like
operating systems, including Linux. The hostname is the label assigned to a device connected to a
computer network. It is often used to identify the system on a local network.
hostname
Examples:
18. history
The history command in Linux is used to display the command history of the current user in
a terminal session. It shows a list of previously executed commands along with their respective
command numbers.
Examples:
19. uptime
The uptime command in Linux is used to display how long the system has been running, as
well as various other system-related information. When you run the uptime command, it provides a
summary that includes the current time, the length of time the system has been running, the number
of users currently logged in, and the system load averages for the last 1, 5, and 15 minutes.
Uptime
Examples:
The last reboot command in Linux provides information about the last time the system was
rebooted. It shows a historical log of system reboots, including the timestamp and information about
who initiated the reboot.
last reboot
Examples:
21. nslookup
The nslookup command is used for querying Domain Name System (DNS) servers to obtain
domain name or IP address mapping, or other DNS records. It's a useful tool for troubleshooting
DNS-related issues and obtaining information about domain names.
Examples:
Examples:
Examples:
c. -size
The -size option allows you to search for files based on their size. You can specify
the size in kilobytes (k), megabytes (M), gigabytes (G), etc.
Examples:
Examples:
1. Find files created within the last 24 hours in the /var/log directory
Command: find /var/log -type f -ctime -1
2. Locate files created between 3 and 7 days ago in the /home directory
Command: find /home -type f -ctime +3 -ctime -7
3. Search for files created exactly 30 days ago in the /opt directory
Command: find /opt -type f -ctime 30
e. -exec
The -exec option is used to execute a command on the files found by find. It allows
you to perform actions on the files, such as running a specific command.
Examples:
1. Find all text files in the current directory and print their contents
Command: find . -type f -name "*.txt" -exec cat {} \;
2. Move all text files to a different directory
Command: find /path/to/search -type f -name "*.txt" -exec mv {}
/path/to/destination/ \;
3. Delete all text files older than 1 day
Command: find /path/to/search -type f -name "*.txt" -ctime +1 -exec rm {}
\;
2. Locate command
The locate command in Linux is used to quickly search for the location of files and
directories on the system. It relies on a pre-built index of the file system, which makes it
faster than other file-searching methods like find. However, keep in mind that the locate
command may not always have the most up-to-date information since its database is
usually updated periodically.
Examples:
3. Whereis command
The whereis command is used to locate the binary, source code, and manual page
files for a command. It searches standard binary directories, manual page directories,
and source code directories.
Examples:
4.Which command
The which command is used to locate the executable file associated with a given
command in the user's PATH.
Examples:
5.Type command
The type command is used to display information about a command, including its
location and whether it is an alias, keyword, function, or a built-in shell command.
Examples: