Linux Flashcards
Remember command
How to check g++ version in system?
dpkg –list | grep compiler
how to update the Ubuntu package list?
sudo apt-get update
How to find location of command?
whereis For example: whereis g++
How to show current path?
pwd
how to completely disabling Touchpad
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)]
What command to show ID, group etc
id
$ ls -l show file attributes, what does the first symbol mean?
- Regular file d Directory l Symbolic link
Read permission of directory allow to ?
Allows file names in the directory to be read
Write permission of directory allow to ?
Allow entries to be modified within the directory like add new file
Execute permission of directory allow to?
Allows access to contents and metadata for entries like the owner, modified date etc..
how to show all users in the system?
less /etc/passwd or getent passwd
How to list all users only for username?
awk -F: ‘{ print $1 }’ /etc/passwd
how to display the list of recent commands in Linux?
history
what is default separator in awk
White-space character which is space or tab
What is the option value to set separator in “awk” command?
-F For example: awk -F: ‘{print $1}’ /etc/passwd
What is $0 in awk?
that repersent the whole line
what is statement control in awk?
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 “statement” structure in awk?
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
What is permission categories?
u:User, g:Group, o:Other and a:All
command ls -l, what is the first column mean?
1st char: type, file, dir or link next 3: user permission rwx next 3: group permission rwx next 3: other permission rwx
How to change permission of file?
chmod and provide u=rwx,g=rwx,o=rwx or we can use u+ or u- or we can use 777