5. Fundermental Daily Linux Commands Flashcards

1
Q

What is the difference between ls and ll?

A

The ls command displays the contents of a given directory.
The ll command not only displays the content but also the content alongside their permissions, creator, date of creation, etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What commands can be used to display the contents of a directory alongside their permissions, creator, date of creation, etc?

A

Either you use ls -l or ll

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Which command is used to display all contents of the directory including hidden files and sub-directories?

A

ls -a

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What commands will be used to display the contents of a directory arranged in ascending or descending order by modification time?

A

ll -tr, for ascending order
ll -t, for descending order

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What command is used to switch the user’s home directory?

A

cd ~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What command is used to display the current directory a user is in?

A

pwd

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which command is used to create a new directory?

A

mkdir directory_name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Which command is used to create nested directories?

A

mkdir -p dir/dir1/dir2/………./dirn

or

mkdir -pv dir/dir1/dir2/………./dirn, for more detailed information about the created directories

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Which command is used to create a file in Linux?

A

touch filename.ext

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What command is used to display text on the terminal?

A

echo “text”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What command is used to display the tree structure of a directory?

A

tree

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What command is used to copy and paste files in Linux?

A

cp filename.ext destination_directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What command is used to move(cut and paste) files in Linux?

A

mv filename.ext destination_directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What command is used to delete a file in Linux?

A

rm filename.txt

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What command is used to delete a directory in Linux?

A

rm -r directory_name

or

rm -rf directory_name ( to remove the directory forcefully)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q
A
17
Q

What command is used to change the name of a file or directory?

A

mv filename newfilename
mv dirname newdirname

18
Q

What will you use to display all the lines in a file that contains a particular string/string of characters?

A

grep “string” filename.ext

grep -i “string” filename.ext (for it to be case insensitive)

19
Q

What command will you use to display all the lines that contain a specific string of characters, in every file in the directory and its sub-directories?

A

grep -r “string” path

20
Q

Which command is used to find a file in a directory?

A

find dir_path -name “filename.ext”

21
Q

Which command is used to list all the directories in a given path?

A

find dir_path -type d

22
Q

What command is used to sort the lines of text in a file and display them?

A

sort filename.ext

23
Q

What command is used to sort the lines of text in a file and display them in Reverse Order?

A

sort -r filename.ext

24
Q

What command is used to sort the lines of text in a file by number and display them?

A

sort -n filename.ext

25
Q

What command is used to sort lines of text in a file by their second column?

A

sort -k2 filename.ext