Lesson 06 - Introduction To CLI
Lesson 06 - Introduction To CLI
Lesson 06 - Introduction To CLI
Introduction to CLI
Learning Objectives
To start the terminal, right click on the mouse and select the option open terminal.
Running Commands as Superuser
A normal user does not have the privilege to perform certain tasks.
The manual pages are further divided into several sections. They are :
• Name
• Synopsis
• Description
• Options
• Exit values
• Files
man -k Command
The type command or which command is used to find the version of a command.
• The system will not identify the files without the inode
numbers.
• Hard links are used to have a backup copy of the file without
having to occupy any additional space.
• Any change in one file gets reflected in all the copied files.
o touch command
o cat command
o vi editor.
• The file created by any of these three methods occupies zero bytes of space.
• After entering the required data in the created file, use the control + d keys to save the file.
Creating Files and Directories
Syntax:
mkdir <directory_name>
In Linux, the command cp is used to copy a file or its contents from one
folder to another folder.
Syntax:
cp <source_filename> <destination_filename>
Copying Files and Directories
Option Description
-i Ask for user permission before writing to the destination file
-b Create a backup copy of the destination file
-f Copy file to the destination file forcefully if you don’t have permission
-p Preserve file attributes if possible
Copying Files and Directories
Syntax:
cp -r <source_dir> <destination_dir>
Renaming Files and Directories
Syntax:
mv <old_file_name> <new_file_name>
Renaming Files and Directories
Syntax:
mv <old_dir_name> <new_dir_name>
Moving Files and Directories
The mv command used for renaming files and directories can be used to move them
to a different location.
Syntax:
mv <source_location> <destination_location>
Moving Files and Directories
Option Description
-i Ask user’s permission before performing the task
-f Ask user’s permission while writing protected files
-n Prevent overwriting of an existing file at destination
-b Backup the destination file
Removing Files and Directories
The rm command which stands for remove is used to delete or remove files and directories.
A directory can be removed only after all the files and directories within it are removed.
df Command
The df command is used to view the file system usage and the mount point of the file system.
df Command
Option Description
-a Display the information about the file systems
-h Display the same file system information in a human readable format
-i List the information of inode
free Command
The free command is used to display the information of memory used by the system.
The top command is used to display the information of processes running in Linux.
Option Description
-a Print the system information in a specific order
-s Print the kernel name
-n Print the hostname
-r Print the kernel version
-v Print the current kernel version
-m Print the machine hardware information
lsb_release Command
The lsb_release command is used to display the installed Linux distributor ID, release
version, and codename.
lsb_release Command
Option Description
-a Print the OS distribution and releases information
-d Display the description
-c Display the code
ip Command
The lspci command displays the machine hardware information based on the PCI architecture.
The information includes PCI bridge, VGA controller, Ethernet controller, USB controller,
audio device, and IDE interface.
lsusb Command
lsusb command is used to display the information of various USB devices connected to the system.
Key Takeaways
Soft links help you refer to a file with a long name with a shorter
version of the name.
A. df
B. mv
C. top
D. rm
Knowledge
Check
Which command is used to view the information of running tasks or processes?
1
A. df
B. mv
C. top
D. rm
The top command is used to view the information of running tasks or processes.
Knowledge
Check
Which command is used to display the manual pages of a command?
2
A. man
B. manual
C. help
D. show
Knowledge
Check
Which command is used to display the manual pages of a command?
2
A. man
B. manual
C. help
D. show
A. cp
B. help cp
C. man cp
D. lsb_release
Knowledge
Check
Which command is used to view the Linux release version?
3
A. cp
B. help cp
C. man cp
D. lsb_release
A. df
B. dd
C. cd
D. mv
Knowledge
Check
Which command is used to know the mount point of a file system?
4
A. df
B. dd
C. cd
D. mv
The df command is used to view the mount point information of a file system.