Flags That You Can Give It Include - A,-L,-F. The - A Flag Simply Outputs The Contents
Flags That You Can Give It Include - A,-L,-F. The - A Flag Simply Outputs The Contents
Question 1:
ls Command:
The ls command principally outputs the contents of your working directory. The
flags that you can give it include -a,-l,-F. The -a flag simply outputs the contents
that are hidden as well so in a way it outputs everything. The -l flag is used for
long listing and outputs detailed information about contents. The -F flag is used to
append an indicator of the file type to a directory.
Cd command:
Cd stands for change directory and is used to do the same. Like if I type cd
Desktop it will change working directory to desktop. The flags include /(which
changes directory to root), ~(return to home directory), ..( to change to
parent directory i.e. go back) etc.
pwd Command:
the pwd command prints the working directory (relative path) to the terminal. The
flags include -L and -P. The -L flag prints the symbolic path while the -P prints
the actual path.
mkdir Command:
the mkdir command can create folders in working directories with certain
permissions etc. The flags include -v,-p. The -v flag is used to display a message
for every directory created. The -p flag is used to parent directories if necessary.
For example if you do mkdir /home/first/second but home or/and first don’t exist,
Linux gives error. The b-p command creates directories if not present.
rmdir Command:
The rmdir command is used to remove the empty folders/directories from your
working directory.
Popular flags include -v,-p. The -p command is used to delete all empty
directories starting from the child directory to the top (if empty) from given
parameters. Like this will delete all mydir and mydir1
The -v flag displays verbose information for every directory being processed.
rm Command:
ls
a.txt b.txt c.txt d.txt e.txt
Removing one file at a time
$ rm a.txt
$ ls
b.txt c.txt d.txt e.txt
$ ls
d.txt e.txt
The flags include -i,-f,-r. The -i flag is used to ask the user is he/she really wants
to delete the file (y for yes n for no). The -f flag is used to forcefully delete files if
some mode is stopping regular rm command from deletion. The -r flag is used to
delete all the files and directories in the parent directory (a dangerous command)
cp Command:
The cp command is used to create mirror image of files into a soure file/directory.
Its implementation depends upon the number of parameters given.
i. Suppose there is a directory named geeksforgeeks having a text file a.txt.
Example:
$ ls
a.txt
$ cp a.txt b.txt
$ ls
a.txt b.txt
$ cat geek.txt
India
$ cat b.txt
geeksforgeeks
$ mv geek.txt b.txt
$ ls
b.txt c.txt d.txt
$ cat b.txt
India
Touch command can be used to create files with no content. Syntax is touch
file_name. Popular flags include -c,-t. The -c flag is used to check if file exits or
not in working directory (if not create then create). The -t flag is used to create
file with some specific timestamp.