I have practiced some terminal-based basic questions. These questions are very basic and important for beginners.
Q1. From your desktop, switch to the third virtual console and log in to your user account. Run a few commands. Then exit the shell and return to the desktop.
ctrl+alt+F6 # virtual console will open
$ pwd
$ ls
$ uname
Once these commands are performed then we can exit the virtual console by pressing ctrl+alt+F7 or ctrl+alt+Fn+F7.
Q2. Find the location of the mount command and the tracepath man page.
man -w mount
locate tracepath
Note -w : option is used to display the location of the manual page file
Q3. Type the following three commands, and then recall and change those commands as described: $ cat /etc/passwd $ ls $HOME $ date
cat /etc/passwd
ls $HOME
date
once these commands are performed we can list them in history with their unique id
a) Use the command-line recall feature to recall the cat command and change / etc/passwd to /etc/group.
fc 2072 #2072 from above history output
#opens the editor and change the value
cat /etc/passwd to cat /etc/group
#save and exit the editor
b) Recall the ls command, determine how to list files by time (using the man page), and add that option to the ls $HOME command line.
fc 2073
#change #HOME as:
ls -t $HOME
#save and exit
c) Add format indicators to the date command to display the date output as month/day/year.
fc 2074 #value taken from history command
#change date
date +%D
Q4. Run the following command, typing as few characters as possible (using tab completion): basename /usr/share/doc/
basename /usr/share/do<Tab> #press tab button to complete it
Q5. Use the cat command to list the contents of the /etc/services file and pipe those contents to the less command so that you can page through it (press q to quit when you are finished).
cat /etc/services | less
Here the cat command's output is passed through the pipe('|') and the result is displayed in partition.
Q6. Run the date command in such a way that the output from that command pro- duces the current day, month, date, and year. Have that read into another command line, resulting in text that appears like the following (your date, of course, will be different): Today is Thursday, December 19, 2019.
echo "TOday is $(date '+%A, %B %d, %y')"
TOday is Sunday, July 02, 23 #output
Q7. Using variables, find out what your hostname, username, shell, and home direc- tories are currently set to.
#type the following commands in terminal as it is
hostname
echo $USER
echo $SHELL
echo $HOME
Q8. Create an alias called mypass that displays the contents of the /etc/passwd file on your screen in such a way that it is available every time you log in or open a new shell from your user account.
vim ~/.bashrc #open the bashrc file in any editor
alias mypass = '/etc/passwd'
#save and exit the editor
source ~/.bashrc # reload the bashrc file in the terminal to update the alias
Q9. Display the man page for the mount system call.
man 2 mount
#system call is typically found in section 2 of the manual page
These were the basic questions of the topics learned on day 2. For the quick revision, you can refer the blog. I hope you got some ideas on how to preform the commands in the terminal. I will bring more stuffs in Linux learning.
Happy learning :)