linux commands Flashcards

(27 cards)

1
Q

Which command shows the size of files and folders in the current directory?

A

du -h

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

How to display the contents of a file line by line with line numbers?

A

nl filename

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

How to execute a file if it is executable? Provide an example

A

./script.sh

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

How to set permissions for groups and users using the chmod command?

A

chmod u+x file:
chmod g+w file:

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

Which command shows the available free space on the disk?

A

df -h

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

How to check the last modification date and time of a file?

A

stat filename

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

What is the difference between the commands ls -l and ls -a?

A

is the difference between the commands ls -l and ls -a?
o ls -l: Lists files in long format, showing permissions, owners, size, and
modification date.
o ls -a: Lists all files, including hidden files (those starting with a dot)

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

How to display the structure of a directory as a tree? Specify the command.

A

tree

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

How to run an application or command in the background?

A

./myprogram &

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

Write a command to display the last 20 commands executed in the terminal.

A

history | tail -20

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

How to clear the terminal screen?

A

clear

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

How to redirect the output of a command to a file?

A

command > filename

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

Write an example of creating a symbolic link to a file.

A

ln -s /path/to/file /path/to/symlink

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

How to find all files of a specific size in a directory?

A

find . -size +100M

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

How to delete all files with the .log extension in the current directory?

A

rm *.log

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

how to create a bash script and make it executable?

A

nano script.sh.
chmod +x script.sh.

17
Q

How to automate script execution during system startup?

A

/etc/rc.local

18
Q

How to check which packages are installed on the system using apt?

A

pt list –installed

19
Q

What is the .bashrc file, and what is it used for?

A

What is the .bashrc file, and what is it used for?

20
Q

How to enable error output in a bash script?

A

Add set -e at the beginning of the script to stop the execution on errors or set -
x to print each command before executing it

21
Q

How to find the current user in Linux? Specify the command.

22
Q

How to terminate a process using the kill command?

A

kill PID (replace PID with the process ID, which you can find using ps or top)

23
Q

Which command is used to change the user password in Linux?

24
Q
  1. How to display the contents of a file with line numbers, starting from a specific line?
A

sed -n ‘5,$=’ filename

25
How to move a file from one directory to another?
mv /path/to/file /path/to/destination
26
Which command combines the contents of multiple files into one file?
cat file1 file2 > combinedfile
27
How to find files in the current directory modified in the last 7 days?
find . -type f -mtime -7