Linux Commands Flashcards

1
Q

Command to show current working directory?

A

pwd

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

Command to show the username?

A

whoami

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

________ is the top-most directory in Linux.

A

root directory

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

________ will take you to the parent directory or one step up.

A

cd ..

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

__________ command will take you to the previous used directory.

A

cd -

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

Different ways to clear the Linux screen?

A

clear
Ctrl + L

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

Command to show all the files or directories?

A

ls

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

Command to display the newest file or directory first?

A

ls -l
ls -lt

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

Command to display the oldest file or directory first?

A

ls -ltr

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

Command to display the oldest file in a directory first?

A

ls -lR

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

How to recursively print all the directories and files?

A

ls -R

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

Command to display all the files including the hidden files that are starting with dot(.)?

A

ls -a

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

What is the Linux command to print all files and folders recursively including the hidden files?

A

ls -R -a
or ls -Ra
or ls -aR

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

What does ls -latR command display?

A

Recursively display all files and directories including the hidden files based on timestamp i.e. the newest one first.
l - long listing.
a - including the hidden files.
t - new ones come first.
R - Recursively print all files and directories.

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

How to create an empty file?

A

touch filename

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

Command used to change permissions of a file?

A

chmod

17
Q

How to change the permission of the file from ‘-rw-r–r–’ to ‘-rwxrw-r–’?

A

chmod 764 filename

18
Q

Command to create a directory?

A

mkdir

19
Q

chmod 644 file1.
What is the permission given to file1?

A

-rw-r–r–

20
Q

Command used to display the content in the file?

A

cat filename

21
Q

How to delete an empty directory?

A

rmdir dirName
This command will only work when a directory is empty and if it is not empty it shows an error.

22
Q

Command to delete a file?

A

rm fileName

23
Q

Command to delete a directory with files in it?

A

rm -R dirName

24
Q

what is the Linux command used to copy?

A

cp

25
Q

The command used to copy file1 to a directory?

A

cp existingFile1 dir1

26
Q

what is the command used to copy an existing file to a new file?

A

cp existingFile1 newFile2

27
Q

Command used to copy directory to another directory?

A

cp -R dir1 dir2
dir1 will be copied to dir2.

28
Q

What command is used to create a file and lets you enter some data into it?

A

vi file1

29
Q

The command used to show the first 10 lines in a file?

A

head filename

30
Q

The command used to show the first 5 lines in a file?

A

head -5 filename

31
Q

The command used to read the last 10 lines in a file?

A

tail filename

32
Q

The command used to display all the content in a file

A

cat filename

33
Q

What command is used to merge/move two files into one file?

A

cat file1 file2 &raquo_space; file3

34
Q

What command is used to search a word from all files?

A

grep word *