0% found this document useful (0 votes)
127 views6 pages

Flags That You Can Give It Include - A,-L,-F. The - A Flag Simply Outputs The Contents

The document summarizes common Linux commands and their functions: 1. The ls command lists directory contents, with options like -a to show hidden files and -l for long listing format. 2. The cd command changes the working directory, allowing users to navigate filesystem locations. 3. Commands like pwd print the working directory, mkdir creates new directories, and rmdir removes empty directories. 4. Other file management commands covered include rm to delete files, cp to copy, mv to move/rename, and touch to modify file timestamps or create empty files.

Uploaded by

Faiq Rauf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
127 views6 pages

Flags That You Can Give It Include - A,-L,-F. The - A Flag Simply Outputs The Contents

The document summarizes common Linux commands and their functions: 1. The ls command lists directory contents, with options like -a to show hidden files and -l for long listing format. 2. The cd command changes the working directory, allowing users to navigate filesystem locations. 3. Commands like pwd print the working directory, mkdir creates new directories, and rmdir removes empty directories. 4. Other file management commands covered include rm to delete files, cp to copy, mv to move/rename, and touch to modify file timestamps or create empty files.

Uploaded by

Faiq Rauf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

1.

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:

rm command is used to remove references to files/objects so once it is done the


deleted object cannot be retrieved.

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

Removing more than one file at a time


$ rm b.txt c.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

ii. Suppose there is a directory named geeksforgeeks having a text file a.txt,


b.txt and a directory name new in which we are going to copy all files.
Example:
$ ls
a.txt b.txt new
Initially new is empty
$ ls new
$ cp a.txt b.txt new
$ ls new
a.txt b.txt
 mv command:

The mv command can be used to replace a source with destination. So it basically


moves files. It can also be used to rename files as source is simple replaced with
destination file (if it doesn’t exist, it is created and contents copied)
Example:
$ ls
b.txt c.txt d.txt geek.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

Popular flags include -i(confirmation message), -f (forcefully write a file if


some mode is protecting it), -n(don’t overwrite a file it already exists)
 touch command:

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.

You might also like