Lecture # 7 - Basic Linux Commands
Basic Commands used in Linux

whoami: The
whoamicommand is used in Linux to display the username of the current user.
pwd: The
pwdcommand in Linux is used to print the current working directory.

ls: The
lscommand in Linux is used to list directory contents.
The ls command has many options. Some are as under:
-> ls -a:
ls-alists all files including hidden files.
-> ls -l:
ls-ldisplays detailed information about each file or directory.
-> ls -lh:
ls -lhdisplays sizes in a human-readable format.
man: The
mancommand in Linux is used to display the manual pages for other commands. This command is written asman [options] [command].When we run the command
man tar, this manual will be shown and we can scroll it to read the whole manual. To close the manual simply press the key 'q'.
clear: The
clearcommand in Linux is used to clear the terminal screen by removing all previous commands.echo: The
echocommand in Linux is used to display a line of text or a string of characters in the terminal. This command is written asecho [options] [command].
The echo command has some options. They are as under:
-> echo -n:
echo -n [command]suppresses the trailing newline, so no newline character is output after the string.
-> echo -e:
echo -e [command]Enables interpretation of backslash escapes. For example,\nwill be interpreted as a newline character.
date: The
datecommand in Linux is used to display or set the current system date and time.-> To display the current date and time in the default format:

-> To display the date and time in a specific format: We will use
date [+FORMAT]to display the date and time in a specific format.
Y: Year, m: month, d: day, H: hours, M: minutes, S: seconds
-> To set the system date and time: We will use
sudo date MMDDhhmm[[CC]YY][.ss]to change the date and time.
You can see the last command and this command. In the last command the time is changed because I only changed the time.
MM: Month, DD: day, hh: hour, mm: minute, [[CC]YY]: year i.e '24' or '2024',
ss: seconds. And remember to add a dot(.) before giving the seconds, also add sudo before the command. Sudo is used for giving permission. We will learn about sudo in our next lectures.
cal: The
calcommand in Linux is used to display a calendar. You'll have to first install the package. For this run the following command in your terminal:sudo apt install ncal. This command is written ascal [options] [month] [year]. Some options of this command are as under:-> cal -3: To display the previous, current, and next month's calendars.

-> cal -y: To display a calendar for the entire year.

-> To display calendars for month and year of your choice: This command is written as
cal [month] [year].
history: The
historycommand in Linux is used to display the list of commands that have been previously executed in the current shell session.
alias: The
aliascommand in Linux is used to create shortcuts or alternate names for longer commands. This command is written as:alias alternate_name='command'.
whoamicommand is used to display the username of the current user. I changed this command and gave it an alternative name username.unalias: The
unaliascommand in Linux is used to remove aliases previously defined for commands.-> To remove the alias for a specific command:
unalias [alternate_name]
-> To remove multiple aliases at once:
unalias [alternate_name1] [alternate_name2]-> To remove all aliases:
unalias -areboot: The
rebootcommand in Linux is used to reboot the system. It restarts the operating system and brings the system back to its initial state.shutdown: The
shutdowncommand in Linux is used to shut down or reboot the system. This command is written as:shutdown [OPTIONS] [TIME] [MESSAGE].-> To shutdown the system immediately:
shutdown -h now-> To shutdown the system in specific time:
shutdown -h [+TIME]
-> To cancel a pending shutdown:
shutdown -c




