Linux Flashcards

Remember command (53 cards)

1
Q

How to check g++ version in system?

A

dpkg –list | grep compiler

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

how to update the Ubuntu package list?

A

sudo apt-get update

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

How to find location of command?

A

whereis For example: whereis g++

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

How to show current path?

A

pwd

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

how to completely disabling Touchpad

A

xinput list xinput set-prop 12 “Device Enabled” 0 Virtual core pointer id=2 [master pointer (3)] ⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)] ⎜ ↳ Logitech USB-PS/2 Optical Mouse id=13 [slave pointer (2)] ⎜ ↳ ImExPS/2 Generic Explorer Mouse id=12 [slave pointer (2)]

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

What command to show ID, group etc

A

id

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

$ ls -l show file attributes, what does the first symbol mean?

A
  • Regular file d Directory l Symbolic link
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Read permission of directory allow to ?

A

Allows file names in the directory to be read

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

Write permission of directory allow to ?

A

Allow entries to be modified within the directory like add new file

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

Execute permission of directory allow to?

A

Allows access to contents and metadata for entries like the owner, modified date etc..

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

how to show all users in the system?

A

less /etc/passwd or getent passwd

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

How to list all users only for username?

A

awk -F: ‘{ print $1 }’ /etc/passwd

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

how to display the list of recent commands in Linux?

A

history

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

what is default separator in awk

A

White-space character which is space or tab

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

What is the option value to set separator in “awk” command?

A

-F For example: awk -F: ‘{print $1}’ /etc/passwd

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

What is $0 in awk?

A

that repersent the whole line

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

what is statement control in awk?

A

if else while do for continue break Example if ( expr ) statement if ( expr ) statement else statement while ( expr ) statement do statement while ( expr ) for ( opt_expr ; opt_expr ; opt_expr ) statement for ( var in array ) statement continue break

awk ‘{if($3 != 0) {a = ($3/$4); print $0, a;} else if($3==0) print $0, “-“ }’ file_name

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

How “statement” structure in awk?

A

Group of statement are blocked via {…} and can be separated by semi-colons or new line For example: awk -F: ‘{if ($3 > 100) { x=x+1; print x, $1, $3} }’ /etc/passwd

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

What is permission categories?

A

u:User, g:Group, o:Other and a:All

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

command ls -l, what is the first column mean?

A

1st char: type, file, dir or link next 3: user permission rwx next 3: group permission rwx next 3: other permission rwx

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

How to change permission of file?

A

chmod and provide u=rwx,g=rwx,o=rwx or we can use u+ or u- or we can use 777

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

What is the command to list file in directory that include file that start name with dot (.)?

23
Q

How to change directory to Home?

24
Q

How to find file name that start wiht utp* from current directory and under?

A

find . -name utp*

25
how to display the execute of ls -l on file that start with uta\* from current directory and under?
find . -name utp\* -exec ls -l {} \; We need {}, find will subsitute {} filename they found. also it need ";" (put \ escape to prevent shell to interpret it)
26
How to list file that size \> 10 Megabite and perform ls -l
find -size +10M -exec ls -l {} \;
27
What command to find executable file?
find . -executable -type f
28
How to unzip zip file from Windows
unzip zip\_file
29
How to grep recursively?
grep -r whatever ./
30
Grep to show line before & after
grep -C5 "xxx"
31
what is default /bin/sh in Ubuntu
dash and in RedHat is bash
32
What is link on linux
Hard link and Soft link ln // this is hard link ln -s this is soft linke we can remove it by rm or --- unlink
33
To create environment variable
export TEST=1234 to show it --- echo $TEST to remove it --- unset $TEST
34
How to list files by newest date?
ls -lt
35
To display host IP address
ifconfig
36
To check ubuntu version
lsb\_release -a
37
How to create short-cut command line?
alias alias ena\_serv = "systemctl list-unit-files | grep enabled" to make it permanent, add those line in ~/.bash\_aliases
38
How to display process in linux
ps aux or top command to display top 5 usage ps aux | ort -nrk s3,3 | head -n 5 to refresh every 2 seconds watch "ps aux | ort -nrk s3,3 | head -n 5"
39
How to kill process
kill -9 "id"
40
How to display all socket
ss -a netstat --listen netstat -ratn
41
How to check memory
free /proc/meminfo top
42
What is the max size of file name?
255
43
How many mode in vi?
3 modes command mode, edit mode and replace mode
44
What commands to see content of file?
cat, head, tail, cat, more, less
45
List of most use network command
netstat -tulpn ping, telnet, tracerout ifconfig -a host www.google.com ip address show
46
How to check disk usage of directory?
du -sh "directory name"
47
show disk usage
df -ah
48
how to check system infomation
uname -a
49
How to check disk mount at boot time
check file /etc/fstab we pronouce "file system tab"
50
How to search contain of file and show 5 lines before & after
grep -C5 "Whatever"
51
What is systemd?
it is stand for "system-deamons" ## Footnote - It work like Window Services. - It is used with sysctrl command.
52
What is /bin/sh
In Unbuntu it is "dash". In RedHat is bash
53