You are on page 1of 12

pwd (Print Working Directory):


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 Example: Running cd /home/user/documents would change the directory


to "/home/user/documents".

cd .. (Change to Parent Directory):


o Explanation: Moves up one level in the directory hierarchy.

o Example: Running cd .. in "/home/user/documents" would move to the


"/home/user" directory.

ls (List Directory Contents):


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.

ls -la (List Detailed Directory Contents):


o Explanation: Lists detailed information about files and directories,
including hidden files.

o Example: Running ls -la would display a detailed list of files and


directories, including hidden files, in the current directory.

mkdir (Make Directory):


o Explanation: Creates a new directory.

o Example: Running mkdir new_folder would create a new directory named


"new_folder" in the current directory.

rmdir (Remove Directory):


o Explanation: Removes an empty directory.

o Example: Running rmdir empty_folder would remove the directory


named "empty_folder" if it is empty.

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 Example: Running echo "Hello, world!" would output "Hello, world!"


in the terminal.
> (Output Redirection):


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.

>> (Append Output):


o Explanation: Redirects the output of a command and appends it to a file.

o Example: Running echo "World!" >> greeting.txt would append the


text "World!" to the end of the "greeting.txt" 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.

o Example: Running mv file.txt


new_directory/file_renamed.txt would move the file "file.txt" to the
"new_directory" and rename it as "file_renamed.txt".

cp (Copy):

o Explanation: Copies files and directories.

o Example: Running cp file.txt backup/file_copy.txt would create a


copy of "file.txt" named "file_copy.txt" in the "backup" directory.

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.

o Example: Running updatedb would update the database, allowing


the locate command to provide up-to-date search results.

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.

For example, let's consider an ls -la output line:

-rwxr-x--- 1 user group 4096 May 10 12:34 myfile.txt

In this example, the permissions are broken down as follows:

 -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).

 1: Indicates the number of hard links to the file.

 user: Refers to the owner of the file.

 group: Refers to the group assigned to the file.


 4096: Indicates the file size in bytes.

 May 10 12:34: Specifies the date and time of the last modification.

 myfile.txt: Represents the name of the file.

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:

chmod (Change Mode):


o Explanation: Changes the permissions of a file or directory.

o Example: Running chmod +x script.sh would add the execute permission


to the file "script.sh", allowing it to be executed as a script.

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.

o Example: Running /etc/sudoers would display the configuration


directives for sudo access and permissions.

sudo -l:


o Explanation: Lists the commands a user is allowed to run
with sudo privileges.

o Example: Running sudo -l would display the commands and permissions


available to the current user with sudo access.

ip a:


o Explanation: Displays the network interfaces and their associated IP
addresses.

o Example: Running ip a would show information about network interfaces,


including their IP addresses, MAC addresses, and other details.

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.

o Example: Running iwconfig would show the configuration details, such as


wireless signal strength, frequency, and encryption information, for active
wireless interfaces.

ip n:


o Explanation: Displays the Neighbor Table, which contains the IP-to-MAC
address mappings for devices in the local network.

o Example: Running ip n would show the IP and MAC addresses of devices


that have recently communicated with the current device.

arp -a:


o Explanation: Displays the ARP (Address Resolution Protocol) cache, which
maps IP addresses to MAC addresses.

o Example: Running arp -a would show the IP and MAC addresses of


devices that have been resolved recently by the ARP protocol.

ip r:


o Explanation: Displays the routing table, which contains information about
network routes.

o Example: Running ip r would show the routing table, including


destination networks, gateway IP addresses, and network interfaces.

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.

echo "hello" > hey.txt:


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.

echo "hello again" >> hey.txt :


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.

o Example: Running touch newfile.txt would create an empty file named


"newfile.txt" if it doesn't exist or update its timestamp if it already exists.

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 Example: Running mousepad newfile.txt would open the Mousepad


editor, where you can enter or modify text in the "newfile.txt" file.

sudo service apache2 start:


o Explanation: Starts the Apache web server service.

o Example: Running sudo service apache2 start would initiate the


Apache web server and make it available for serving web pages.

sudo service apache2 stop:


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.

python3 -m http.server 80:


o Explanation: Starts a simple HTTP server using Python on port 80.

o Example: Running python3 -m http.server 80 would start a basic HTTP


server on port 80, allowing you to serve files from the current directory.

sudo systemctl enable ssh:


o Explanation: Enables the SSH (Secure Shell) service to start automatically
on system boot.

o Example: Running sudo systemctl enable ssh would configure the


system to start the SSH service during system startup.

sudo systemctl disable ssh:


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.

You might also like