Linux Flashcards

Remember command

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 (.)?

A

ls -a

23
Q

How to change directory to Home?

A

cd ~

24
Q

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

A

find . -name utp*

25
Q

how to display the execute of ls -l on file that start with uta* from current directory and under?

A

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
Q

How to list file that size > 10 Megabite and perform ls -l

A

find -size +10M -exec ls -l {} \;

27
Q

What command to find executable file?

A

find . -executable -type f

28
Q

How to unzip zip file from Windows

A

unzip zip_file

29
Q

How to grep recursively?

A

grep -r whatever ./

30
Q

Grep to show line before & after

A

grep -C5 “xxx”

31
Q

what is default /bin/sh in Ubuntu

A

dash and in RedHat is bash

32
Q

What is link on linux

A

Hard link and Soft link

ln <source></source> <link></link> // this is hard link</source>

ln -s <source></source> <link></link> this is soft linke</source>

we can remove it by

rm <link></link>

or — unlink <link></link>

33
Q

To create environment variable

A

export TEST=1234

to show it — echo $TEST

to remove it — unset $TEST

34
Q

How to list files by newest date?

A

ls -lt

35
Q

To display host IP address

A

ifconfig

36
Q

To check ubuntu version

A

lsb_release -a

37
Q

How to create short-cut command line?

A

alias

alias ena_serv = “systemctl list-unit-files | grep enabled”

to make it permanent, add those line in ~/.bash_aliases

38
Q

How to display process in linux

A

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
Q

How to kill process

A

kill -9 “id”

40
Q

How to display all socket

A

ss -a

netstat –listen

netstat -ratn

41
Q

How to check memory

A

free

/proc/meminfo

top

42
Q

What is the max size of file name?

A

255

43
Q

How many mode in vi?

A

3 modes

command mode, edit mode and replace mode

44
Q

What commands to see content of file?

A

cat, head, tail, cat, more, less

45
Q

List of most use network command

A

netstat -tulpn

ping, telnet, tracerout

ifconfig -a

host www.google.com

ip address show

46
Q

How to check disk usage of directory?

A

du -sh “directory name”

47
Q

show disk usage

A

df -ah

48
Q

how to check system infomation

A

uname -a

49
Q

How to check disk mount at boot time

A

check file

/etc/fstab

we pronouce “file system tab”

50
Q

How to search contain of file and show 5 lines before & after

A

grep -C5 “Whatever”

51
Q

What is systemd?

A

it is stand for “system-deamons”

  • It work like Window Services.
  • It is used with sysctrl command.
52
Q

What is /bin/sh

A

In Unbuntu it is “dash”.

In RedHat is bash

53
Q
A