Prev. >> Linux Command Tricks – II

mv command

Move filename into <path>/<directory-name>

mv <filename> <path>/directory-name>/

Rename filename1 to filename2

mv <filename1> <filename2>

-i: Interactive – ask the user for confirmation before moving a file that would overwrite an existing file,
Press y for confirming the move and any other key leaves the file as it is.
-f: Force – overrides minor protection of confirmation before overwriting the destination file if a file is write protected and overwrite the destination file forcefully and delete the source file.
-n: no-clobber): prevent an existing file from being overwritten.
-b: backup – takes a backup of an existing file and create a backup file with the tilde character(~) appended to it that will be overwritten as a result of the mv command.
–version: to display the version of mv which is currently running on your system.

pwd command

displays the name of the current directory with its pathname

-L: Logical – If the environment variable PWD contains an absolute name of the current directory with no “.” or “..” components, then output those contents, even if they contain symbolic links.
-P: physical display a fully resolved name for the current directory, in which all components of the name are actual directory names, and not symbolic links.
–help: display a help message

pwd --help

–version: display version information

pwd --version

rm command

Removes the specified file or directory

rm <filename>

Removes an entire directory recursively with its included files and sub-directories

rm -r <name>

Delete the specified directory

rmdir <directory-name>

-f: force – ignore nonexistent files, never prompt
-i: prompt before every removal
-I: prompt once before removing more than three files, or when removing recursively
–interactive[=WHEN]: prompt according to WHEN: never, once (-I), or always (-i). Without WHEN, prompt always
–one-file-system: when removing a hierarchy recursively, skip any directory that is on a file system different from that of the corresponding command line argument
–no-preserve-root: do not treat `/' specially
–preserve-root: do not remove `/' (default)
-v: verbose
–help: display this help and exit
–version: output version information

Prev. >> Linux Command Tricks – II