Execution of various file/directory handling Unix/Linux commands

1) pwd COMMAND:
pwd – Print Working Directory. pwd command prints the full filename of the current working directory.

SYNTAX:
The Syntax is
pwd [options]

2) cd COMMAND:
cd command is used to change the directory.

SYNTAX:
The Syntax is
cd [directory | ~ | ./ | ../ | – ]

3) ls COMMAND:
ls command lists the files and directories under current working directory.

SYNTAX:
The Syntax is
ls [OPTIONS]… [FILE]

OPTIONS:

-l Lists all the files, directories and their mode, Number of links, owner of the file, file size, Modified date and time and filename.
-t Lists in order of last modification time.
-a Lists all entries including hidden files.
-d Lists directory files instead of contents.
-p Puts slash at the end of each directories.
-u List in order of last access time.
-i Display inode information.

4) rm COMMAND:
rm linux command is used to remove/delete the file from the directory.
SYNTAX:
The Syntax is
rm [options..] [file | directory]

OPTIONS:

-f Remove all files in a directory without prompting the user.
-i Interactive. With this option, rm prompts for confirmation before removing any files.

5) mv COMMAND:
mv command which is short for move. It is used to move/rename file from one directory to another. mv command is different from cp command as it completely removes the file from the source and moves to the directory specified, where cp command just copies the content from one file to another.

SYNTAX:
The Syntax is
mv [-f] [-i] oldname newname

OPTIONS:
-f This will not prompt before overwriting (equivalent to –reply=yes). mv -f will move the file(s) without prompting even if it is writing over an existing target.
-i Prompts before overwriting another file.

6) cat COMMAND:
cat linux command concatenates files and print it on the standard output.
SYNTAX:
The Syntax is
cat [OPTIONS] [FILE]…
OPTIONS:
-A Show all.
-b Omits line numbers for blank space in the output.

-E Displays a $ (dollar sign) at the end of each line.
-n Line numbers for all the output lines.

7) cmp COMMAND:
cmp linux command compares two files and tells you which line numbers are different.

SYNTAX:
The Syntax is
cmp [options..] file1 file2
OPTIONS:

– c Output differing bytes as characters.
– l Print the byte number (decimal) and the differing byte values
(octal) for each difference.
– s Prints nothing for differing files, return exit status only.

8) cp COMMAND:
cp command copy files from one location to another. If the destination is an existing file, then the file is overwritten; if the destination is an existing directory, the file is copied into the directory (the directory is not overwritten).

SYNTAX:
The Syntax is
cp [OPTIONS]… SOURCE DEST

10) echo COMMAND:
echo command prints the given input string to standard output.
SYNTAX:
The Syntax is
echo [options..] [string]

11)mkdir COMMAND:
mkdir command is used to create one or more directories.

SYNTAX:
The Syntax is
mkdir [options] directories
OPTIONS:

-m Set the access mode for the new directories.
-p Create intervening parent directories if they don’t exist.
-v Print help message for each directory created.
12) paste COMMAND:
paste command is used to paste the content from one file to another file. It is also used to set column format for each line.

SYNTAX:
The Syntax is
paste [options]

OPTIONS:

-s Paste one file at a time instead of in parallel.
-d Reuse characters from LIST instead of TABs .

13) rmdir COMMAND:
rmdir command is used to delete/remove a directory and its subdirectories.
SYNTAX:
The Syntax is
rmdir [options..] Directory

OPTIONS:

-p Allow users to remove the directory dir name and its parent directories which become empty.

Leave a Comment

Leave a Reply