One day One Command(CLI)

Anish Kumar - Oct 30 - - Dev Community

Day 1: pwd
1.pwd: This command stands for Print Working Directory. As the name suggests it helps us know the current/working directory.
Syntax: pwd
1 a.pwd -P: Stands for pwd physical. It returns the current physical directory ignoring all the symbolic links in the path.
Syntax: pwd -P
1 b.pwd -L: Stands for pwd logical. It returns the current logical directory completely preserving the symbolic links in the path.
Syntax: pwd -L

Day 2: poweroff

$ sudo poweroff The poweroff command shuts down the system safely and immediately terminating all processes where unsaved work could be lost. It also unmounts all file systems then powers off the hardware. It is a quick way to turn off the system safely. Users in most cases cannot operate this command without sudo.
$ sudo poweroff --force This command shuts the down the system immediately without terminating any processes. It is generally unsafe to do so. It could be used if the system is unresponsive.
$ sudo poweroff --halt This command works just the way poweroff works but it does not finally cut the power to the hardware systems. It could be used if you want to terminate all the current running processes.

Day 3: ls

  1. ls: The ls command stands for list and it is used to list the files and directories. If used simply without any context it lists the files and directories in the current working directory. It can also be used to list files in other directories by following it up with the path to the directory. To list the files and directories of a file that requires root access we can use sudo on which otherwise we get permission denied. Syntax:ls ls /path/of/directory sudo ls /path/of/restricted directory 3 a.ls -l: This command does the same as ls files with more details. It gives more details such as permissions, ownership, size, date last modified, etc. Syntax:ls -l 3 b.ls -a:This command like the ls file also shows files and directories including hidden ones. Those files usually start with a '.'. Syntax:ls -a 3 c.ls -lh:It is just like ls -l but is in a more human readable format. The sizes are mentioned in kb,mb, etc.

Day 4: cat

  1. cat: This command stand for concatenate. When used on a file it shows the content of the file. If used on executable files or on files containing images they usually return garbled text and symbols as it is interpreting binary data. This command can also copy the content of a file and append it to another file. cat file1 >> file2 appends the contents of file1 to file2. It can also combine two files and copy it to another file. cat file1 file2 > newfile combines the contents of file1 and file2 in newfile. Syntax: cat filename cat file1 >> file2 cat file1 file2 > newfile 4 a.cat -n: This command does the same as cat and numbers all the lines in the output. Syntax: cat -n filename 4 b.cat -b: This command does the same as cat -n but it doesn't number the blank lines. Syntax: cat -b filename 4 c.cat -s: This command does the same as the cat command but it suppresses repeated blank lines into only one blank line. Syntax: cat -s filename 4 d.cat -T: This command does the same as cat but show tabs as ^I helping us differentiate between tabs and spaces. Syntax: cat -T filename 4 e.cat -E: This command is similar to cat -n and instead of numbering all the lines it leaves the $ symbol at the end of a line to help us distinguish between the end of a line or if they just continue. Syntax: cat -E filename 4 f.cat -A: This command is a combination of cat -E and cat -T where it shows the end of each line by leaving a $ symbol and helps distinguishing spaces from tabs by replacing tabs with ^I. Syntax: cat -A filename

Some of these options can be used together.
For eg: cat -ns numbers the lines from start and shortens the repeated blank lines to just one and the numbering is done on the remaining blank line. cat -ET does the same as cat -A. cat -bE numbers only the non blank lines leaves a $ symbol at the end of a line, etc.

Day 5: echo

  1. echo: The echo command sends a message or a variable to all active users or can be used to create or overwrite files. Syntax: echo "Hi everyone" echo $HOME echo "the text" > filename.extension

5 a.echo -e: This command works the same way as echo does but it takes in escape sequences as well. For eg: \n,\t,etc.
Syntax: echo -e "First Line\nNext Line"

. . .
Terabox Video Player