Commands
Commands
o Explanation: Displays the current working directory.
o Example: Running pwd in the terminal would show the absolute path of the
current directory, such as "/home/user/documents".
cd (Change Directory):
o Explanation: Allows you to change the current working directory.
o Explanation: Moves up one level in the directory hierarchy.
o Explanation: Lists the files and directories in the current directory.
o Example: Running ls would display the files and directories in the current
directory.
o Explanation: Lists detailed information about files and directories,
including hidden files.
o Explanation: Creates a new directory.
o Explanation: Removes an empty directory.
man (Manual):
o Explanation: Displays the manual pages for a specified command.
o Example: Running man ls would show the manual pages with detailed
information about the ls command.
echo:
o Explanation: Displays text or variables as output.
o Explanation: Redirects the output of a command to a file and overwrites the
file if it already exists.
o Example: Running echo "Hello" > greeting.txt would write the text
"Hello" to a file named "greeting.txt" or overwrite the file if it exists.
o Explanation: Redirects the output of a command and appends it to a file.
rm (Remove):
o Explanation: Deletes files or directories.
o Example: Running rm file.txt would delete the file named "file.txt" from
the current directory.
mv (Move):
o Explanation: Moves or renames files and directories.
cp (Copy):
o Explanation: Copies files and directories.
locate:
o Explanation: Searches for files and directories in a prebuilt database.
o Example: Running locate myfile.txt would search for the file named
"myfile.txt" in the prebuilt database and display its path if found.
updatedb:
o Explanation: Updates the database used by the locate command to reflect
recent changes in the file system.
passwd:
o Explanation: Allows a user to change their password.
o Example: Running passwd would prompt the user to enter their current
password and then set a new password.
Remember to exercise caution when using commands like rm as they can permanently
delete files. It's always a good practice to double-check before executing such commands.
In the ls -la output, the "rwx" refers to the permissions associated with a file or
directory. The permissions are displayed for three different entities: the owner, the group,
and other users. Each entity has three permission categories: read (r), write (w), and
execute (x). Here's a breakdown of what each permission category represents:
Read (r): Allows the entity to read or view the contents of a file or the names of
files within a directory.
Write (w): Enables the entity to modify or write to a file or add, delete, or rename
files within a directory.
Execute (x): Grants the entity the permission to execute a file or enter a directory.
For directories, execute permission is required to access its contents.
In the ls -la output, the permissions are displayed as a series of nine characters. The
first character represents the file type (e.g., - for a regular file, d for a directory). The next
three characters represent the owner's permissions, followed by the group's permissions,
and then the permissions for other users.
-rwxr-x---: The first character indicates that it is a regular file. The following
three characters (rwx) represent the owner's permissions (read, write, and execute).
The next three characters (r-x) represent the group's permissions (read and
execute). The last three characters (---) represent the permissions for other users
(no permissions).
May 10 12:34: Specifies the date and time of the last modification.
It's worth noting that if a permission is not granted for a particular entity, a hyphen (-) is
displayed in its place. Additionally, the output can include additional information such as
special permissions, ownership, and timestamps.
Here are explanations and examples of the commands mentioned in this video. Please
note, Teachable blocks the mention of some of the sensitive paths shown in the video, so
we cannot display them in text format here:
o Explanation: Changes the permissions of a file or directory.
adduser:
o Explanation: Creates a new user account.
o Example: Running adduser john would create a new user account with the
username "john" and prompt for additional user information.
su (Switch User):
o Explanation: Allows a user to switch to another user account.
o Example: Running su jane would switch to the user account "jane" after
entering the password for that account.
/etc/sudoers:
o Explanation: Displays the content of the "/etc/sudoers" file, which contains
configuration information for the sudo command.
sudo -l:
o Explanation: Lists the commands a user is allowed to run
with sudo privileges.
ip a:
o Explanation: Displays the network interfaces and their associated IP
addresses.
ifconfig:
o Explanation: Displays the configuration and status of network interfaces.
o Example: Running ifconfig would show the configuration details,
including IP addresses, MAC addresses, and other information for active
network interfaces.
iwconfig:
o Explanation: Displays the configuration and status of wireless network
interfaces.
ip n:
o Explanation: Displays the Neighbor Table, which contains the IP-to-MAC
address mappings for devices in the local network.
arp -a:
o Explanation: Displays the ARP (Address Resolution Protocol) cache, which
maps IP addresses to MAC addresses.
ip r:
o Explanation: Displays the routing table, which contains information about
network routes.
route:
o Explanation: Displays or manipulates the IP routing table.
o Example: Running route would display the routing table, similar to the ip
r command.
ping:
o Explanation: Sends ICMP echo requests to a specified IP address to check
network connectivity and measure round-trip time.
o Example: Running ping 8.8.8.8 would send ICMP echo requests to the IP
address "8.8.8.8" (Google's DNS server) and display the round-trip time
and packet loss statistics.
o Explanation: Creates a new file named "hey.txt" with the content "hello"
and overwrites the file if it already exists.
o Example: Running echo "hello" > hey.txt would create a file named
"hey.txt" and write the word "hello" into it.
o Explanation: Appends the content "hello again" to an existing file named
"hey.txt" or creates a new file if it doesn't exist.
o Example: Running echo "hello again" >> hey.txt would append the
text "hello again" to the end of the "hey.txt" file.
touch newfile.txt:
o Explanation: Creates a new empty file named "newfile.txt" or updates the
timestamp of an existing file to the current time.
nano newfile.txt:
o Explanation: Opens the text editor Nano and allows you to create or edit the
content of a file named "newfile.txt".
o Example: Running nano newfile.txt would open the Nano editor, where
you can enter or modify text in the "newfile.txt" file.
mousepad newfile.txt:
o Explanation: Opens the Mousepad text editor and allows you to create or
edit the content of a file named "newfile.txt".
o Explanation: Starts the Apache web server service.
o Explanation: Stops the Apache web server service.
o Example: Running sudo service apache2 stop would halt the running
Apache web server, shutting down any active web page serving.
o Explanation: Starts a simple HTTP server using Python on port 80.
o Explanation: Enables the SSH (Secure Shell) service to start automatically
on system boot.
o Explanation: Disables the SSH service from starting automatically on
system boot.
o Example: Running sudo systemctl disable ssh would prevent the SSH
service from starting automatically during system startup.