Practicing Unix/ Linux: Command Lines Exercises

btd
35 min readJan 30, 2024
Outline:

I. Command
II. egrep/ grep
III. Regular Expression/ Shell Globbing
IV. Syntax

Identify cmd name options, arguments if any, in the following cmd lines.

$ ls -l / /usr .
  • Command: ls
  • Options: -l
  • Arguments: /, /usr, .
  • Explanation: This ls command is used to list the contents of directories.
  • ls: This command is used to list directory contents.
  • -l: This option specifies a long listing format, providing detailed information about each file or directory.
  • /: This is the root directory of the filesystem. When used as an argument to ls, it lists the contents of the root directory.
  • /usr: This is a directory typically containing user binaries, libraries, and other shared resources.
  • .: This represents the current directory. When used as an argument to ls, it lists the contents of the current directory.
$ cat /etc/passwd ../../project
  • Command: cat
  • Arguments: /etc/passwd, ../../project
  • Explanation: This cat command is used to concatenate and display the contents of files.
  • cat: This command is used to concatenate and display the contents of files.
  • /etc/passwd: This is the path to the /etc/passwd file, which typically contains user account information.
  • ../../project: This is a relative path to a directory named "project" that is located two levels above the current directory.

Write a command line to display bottom 3 lines of the file /etc/passwd

$ tail -n 3 /etc/passwd
  • tail: This command is used to display the last part of a file.
  • -n 3: This option specifies to display the last 3 lines of the file.
  • /etc/passwd: This is the path to the /etc/passwd file, which typically contains user account information.
# Terminal:
[btramduong0810@voyager cis18a]$ tail -n 3 /etc/passwd…

--

--