Busy. Please wait.
or

show password
Forgot Password?

Don't have an account?  Sign up 
or

Username is available taken
show password

why


Make sure to remember your password. If you forget it there is no way for StudyStack to send you a reset link. You would need to create a new account.
We do not share your email address with others. It is only used to allow you to reset your password. For details read our Privacy Policy and Terms of Service.


Already a StudyStack user? Log In

Reset Password
Enter the associated with your account, and we'll email you a link to reset your password.

Remove ads
Don't know
Know
remaining cards
Save
0:01
To flip the current card, click it or press the Spacebar key.  To move the current card to one of the three colored boxes, click on the box.  You may also press the UP ARROW key to move the card to the "Know" box, the DOWN ARROW key to move the card to the "Don't know" box, or the RIGHT ARROW key to move the card to the Remaining box.  You may also click on the card displayed in any of the three boxes to bring that card back to the center.

Pass complete!

"Know" box contains:
Time elapsed:
Retries:
restart all cards




share
Embed Code - If you would like this activity on your web page, copy the script below and paste it into your web page.

  Normal Size     Small Size show me how

Linux

Interview Questions

QuestionAnswer
What is the difference between a hard link and a soft link? A soft link is a pointer to an inode. A hard link creates another file that links to the inode
What is an inode? An Inode is a data structure that contains pointers to the fie blocks , permissions, ownership info and times of last access
What is a data structure? A way to store and organize data.
List of data structures: Primitive - int , float, bool Linear - Arrays , lists Abstract - queue,stack, string, tree,heaps Hashes
Network OSI (7) Layers 7. Application 6. Presentation Layer 5. Session Layer 4. Transport Layer 3. Network Layer 2. DATA Link Layer 1. Physical Layer
How to find the kernel version? uname -r cat /proc/version dmesg | grep Linux
How to find network interfaces /sbin/ifconfig -a netstat -i
Remove blank lines vi g/^$/d
Vi - start of the line? shift ^
Attach a zip to mail? uuencode price_request2.gz price_request2.gz | mail michael.castaneda@ms.com
awk to and from using line numbers? cat fxconnect.log | awk 'NR==40159,NR==122606'> ~/price_request
Vi: show line numbers :set number
The top five processes in total cpu time ps -eo pcpu,pid,user,args | sort -k 1 -r | head -6
The top five processes in resident memory usage ps ax -o rss,command | sort -nr | head -n 5
The current cpu load of the machine uptime | awk -F ", " '{print $4,$5,$6}'
The average file size per directory under /home ls -l | gawk '{sum += $5; n++;} END {print sum/n;}'
Context switch A context switch is the process of storing and restoring the state (context) of a process so that execution can be resumed from the same point at a later time.
A 30 second sample of number of context switches on the host. vmstat 1 30 (cs)
What is Resident memory? resident memory typically refers to physical RAM installed in the machine.
What is Virtual Memory? VIRT = SWAP + RES.
A 30 second sample of the average service time for each of the physical disks attached to the node. iostat 1 30
A 30 second sample of the average service time for each of the physical disks attached to the node. iostat -x 1 30 (svctm)
Any retransmits on any of its interfaces netstat -s | grep -i retransm
How to permanently set $PATH on Linux? PATH=$PATH:/usr/local/bin; export PATH echo 'export PATH=$PATH:/usr/local/bin' >> ~/.profile
How do give access to a file with a delay rsync options source destination--allows encryption of data using ssh protocol,fast,light (allows encription),no permissions
lsof List open files
strings strings - print the strings of printable characters in files.q
ldd ldd - print shared library dependencies
taskset taskset - retrieve or set a processes's CPU affinity
how many cpus cat /proc/cpuinfo
How to find load on all CPUs mpstat -P ALL
find dup fields in a file. cat sym.txt | awk -F "," '{print $2}' | sort | uniq -c
Memory map pmap <pid>
Linux port and pid lsof -n -i -P
FIX :Cut the 59 characters: grep 35=R usdsgd | cut -c -59
FIX: Cut between x and y grep 35=R usdsgd | cut -c 34-59
vi:mass substitution :%s/tnla/smd/g
Backups date +%Y%m%d
Excel Date: =today()
What is Sticky Bit? Sticky Bit is mainly used on folders in order to avoid deletion of a folder and its content by other users though they having write permissions on the folder contents.
How can I setup Sticky Bit for a Folder? chmod 1757 /opt/dump/ chmod o+t /opt/dump/
Checking if a folder is set with Sticky Bit or not? Use ls –l to check if the x in others permissions field is replaced by t or T
What is the ILO integrated lights out component on the server. This is a card which is integrated to the board which allows you to connect to the server remotely and even if Linux doesn’t work. It has it’s own network connection,
Vi:delete lines starting with 'n' :g/^n/d
Vi:delete blank lines :g/^$/d
geting historical data from Sar sar -f /var/log/sa/sa01
awk thrid line df -h . | awk -F " " 'NR==3 {print $4}'
get a core dump kill -6
vi:turn off highlight search set nohlsearch
ssh a command ssh xldn0027xpap 'find /home/sec_infra/AutoRelease.new' ssh vivek@www1.cyberciti.biz 'free -m' > /tmp/memory.status
Bash Shell Temporarily Disable an Alias (highlighing) no alias
A Lun A LUN is a chunk of disk effectively
Out of Memory (OOM) Out of Memory (OOM) computing state where all available memory, including swap space, has been allocated. Normally this will cause the system to panic and stop functioning as expected.
OOM Killer There is a switch that controls OOM behavior in /proc/sys/vm/panic_on_oom. When set to 1 the kernel will panic on OOM.A setting of 0 instructs the kernel to call a function named oom_killer on an OOM.
oom_killer is on. -bash-3.2$ cat /proc/sys/vm/panic_on_oom 0
How many cores does each CPU have? Each core can handle a load average of 1.
making column based file paste mvoo CHG.bat >DOS
check space space /proc/swaps
host xldn0191pap xldn0191pap.wproxy.swissbank.com is an alias for xldn0191pap.ldn.swissbank.com. xldn0191pap.ldn.swissbank.com has address 14.64.128.103
process name from the command line ps -p 26678 -o comm=
trace system calls and signals strace,strace -p 26678
find files over a certain limit find /sbcimp/dyn/logfiles/market_infra/ION/PROD1/ -size +999M
find file by pattern find /sbcimp/dyn/data/market_infra/ION/PROD1/ -name '*.jinit'
one liner: find,grep,awk find /sbcimp/dyn/data/market_infra/ION/PROD1/ -name '*jinit' | xargs egrep "component|host|port|LISTEN" | awk -F "." '{print $3,$4}
This will cause the stderr ouput of a program to be written to a file. grep da * 2> grep-errors.txt
This will cause the stderr ouput of a program to be written to the same filedescriptor than stdout. grep da * 1>&2
if you want a command to pass in absolute silence. &> /dev/null
sar checking over time sar 'how many times inbetween checks' 'how many seconds to check'
find host aliases ypcat hosts |grep xldn2106vpap
check swapping (pagging) cat /proc/meminfo
context switch the process of storing and restoring the state (context) of a process or thread so that execution can be resumed from the same point at a later time.
proc interrupts watch -tdn1 cat /proc/interrupts
Chmod 7,full,111|6,read and write,110|5,read and execute,101|4,read only,100|3,write and execute ,011|2,write only,010,1,execute only,001|0,none 000|
time of last system boot who -b
print dead processes who -d
print current runlevel who -r
find grep find . -name *.log -type f -exec grep "14.2.229.67" {} \;
64 bit ? uname -m x86_64
find recursively through links find . -name espeed.init -type f -follow -print
Clear screen. keybroad short cut. # This is usually equivilent to running 'clear'. Its usually quicker and doesn't leave the command in your command line history.
Ftp - mget * no interactive prompt mget *
Red Hat 5, Red Hat 6 2.6.18,2.6.32
ssh diff (side by side) diff -y <(ssh -q xstm0145vpap 'ls -1 /sbcimp/dyn/data/market_infra/ION/PROD1/REPO/US_REPO_TRADEWEB') <( ssh xstm2480vpap -q 'ls -1 /sbcimp/dyn/data/market_infra/ION/PROD2/REPO/US_REPO_TRADEWEB')
one liner: sqlplus echo "select CCONSOL from FOSORG_ALT_ACR_MAP_DATA_FIELDS;" | /sbcimp/run/tp/oracle/client/v10.2.0.2.0-32bit/bin/sqlplus -s un/pw@smalpnp1
Hits per hour apache log awk -F: '{print $2}' access_log | sort | uniq -c
qtree A special subdirectory in a volume that acts as a virtual subvolume with special attributes, primarily quotas and permissions. A qtree is a special subdirectory under the root volume directory.
na_qtree Creates and manages qtrees. A qtree is similar in concept to a partition. It creates a subset of a volume to which a quota can be applied to limit its size. As a special case, a qtree can be the entire volume.
sadf sadf can generate sar report in CSV, XML, and various other formats. Use this to integrate sar data with other tools.
iostat generates CPU, I/O statistics
mpstat displays CPU statistics.
sar -u 1 3 Displays real time CPU usage every 1 second for 3 times.
sar -r Memory Free and Used
sar -u 1 3 Displays real time CPU usage every 1 second for 3 times.
sar -B generate paging statistics. i.e Number of KB paged in (and out) from disk per second.
sar -W generate page swap statistics. i.e Page swap in (and out) per second.
Max amount of files cat /proc/sys/fs/file-max
system controls cat /etc/sysctl.conf
max pids cat /proc/sys/kernel/pid_max
ulimit -a
attached a zip file uuencode PSH_17_11_2014_copy.log.gz PSH_17_11_2014_copy.log.gz | mail -a /sbcimp/dyn/data/market_infra/ION/PROD2/RATES/LDN_RATES_ROUTER_ICE_FUTURES/LOGS/PSH_17_11_2014_copy.log.gz michael.castaneda@ubs.com
tar gz tar -cvf LDN_CDS_BGC_CDS_archive.tar.gz LDN_CDS_BGC_CD
crontab every five minutes */5 * * * * /home/ramesh/backup.sh
inserts:host at the beginning of each line :%s/^/host /
awk command cat Daemons_Monitor_14-1.2015.txt| sed s/\"//g | awk -F "," '{printf("ssh -q %s ps -ef | grep %s/mkvd.lx |grep -v grep \n", $10,$1)}'
Where are the stack and heap stored? They are both stored in the computer’s RAM (Random Access Memory).
Remove all at jobs atq | sed 's_\([0-9]\{1,8\}\).*_\1_g' | xargs atrm
Find recent logs that contain the string "Exception" find . -name '*.log' -mtime -2 -exec grep -Hc Exception {} \; | grep -v :0
Generate a sequence of numbers $ for ((i=1; i<=10; ++i)); do echo $i; done
Create a heap dump of a Java process $ jmap -dump:format=b,file=/var/tmp/dump.hprof 1234
Sort and remove duplicate lines from two (or more files). Display only uniq lines from files. $ uniq -u <(sort file1 file2)
Compute factorial of positive integer $ fac() { (echo 1; seq $1) | paste -s -d\* | bc; }
Show 10 Largest Open Files lsof / | awk '{ if($7 > 1048576) print $7/1048576 "MB" " " $9 " " $1 }' | sort -n -u | tail
Print the first seven lines of a file: sed 7q
Day of the year date +'%j'
Delete blank lines: awk NF
ls -X will group files by extension. ls -X will group files by extension.
Look for the process bound to a certain port sudo netstat -tulpn | grep :8080
Rename file to same name plus datestamp of last mv -iv $FILENAME{,.$(stat -c %Z $FILENAME)}
Thread count by process, sorted + total ( ps -U nms -o pid,nlwp,cmd:500 | sort -n -k2) && (ps h -U nms -o nlwp | paste -sd+ | bc)
How many cores grep -c ^processor /proc/cpuinfo
vmstat bi/bo checks disk activity
vmstat si/so checks paging
Free -m -t totall virtual memory Mem total + swap total
sar -R 2 0 sar -R 1 30 gives the rate of change of memory usuage
sar -W 2 0 shows number of pages read in from swap
watch free -m -t shows real time (watch)
watch -n1 pmap views memory usage of the process
sar -B 1 30 all i/o over all devices
Find swap partitions /proc/fstab
find swap space df -h /proc/swaps
freespace rss
frmpg/s Number of memory pages freed by the system per second. A negative value represents a number of pages allocated by the system. Note that a page has a size of 4 kB or 8 kB according to the machine architecture.
bufpg/s Number of additional memory pages used as buffers by the system per second. A negative value means fewer pages used as buffers by the system.
campg/s Number of additional memory pages cached by the system per second. A negative value means fewer pages in the cache.
ps axo comm,pid,stat,psr | grep -e kswapd -e pdfush shows the relevant processes along with their state and the processor on which that are running
psr processor that process is currently assigned to
grep Committed_AS /proc/meminfo show an estimate of how much much RAM is needed to aviod an out of memory(OOM) condition
system overview vmstat -s
awk sum mpstat -P ALL | awk -F " " '{ sum+=$3} END {print sum}'
grep command: Recursively Search All Files For A String grep -r "word" .
Yesterdays date date -d "1 day ago" '+%Y-%m-%d'
scp scp sec_infra@xstm5713pap:USTOM.tar.gz .
tar up everything tar -czvf file.tar *
I want to tar up everything except dir1 tar --exclude=main_dir/dir1 -cvzf tarred_file.gz main_dir/ orfind . -path './dir1*' -prune -o -path './*' -exec tar -czvf documents.tar {} \+
view tar tar -tf US_USTOM_TRVET.tar
bc float bc -l <<< 1/3
for i in `cat /sbcimp/dyn/data/market_infra/ION/clarion/PROD1/processes/hosts.txt`; do echo $i; ssh -q -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $i "ps -eaf | grep -i mkvd | awk {'print $8'}| cut -d / -f 8| grep -v grep"; done
check for locked files cat /proc/locks
isql one liner isql -S TK_IONP1_SQL -U birad_ion_dbo -i /home/castanmc/bin/SQL/lun_space.sql
UPPER echo CotPoints_USD.csv | tr '[:lower:]' '[:upper:]'
yesterday's logs nice find *$(date +'%Y%m%d' --date="1 days ago" )* -size +500M -exec gzip -9 {} \;
Diff to strings diff <(echo 755c7bdb635806a184e2c57dd152e6f4) <(echo 755c7bdb635806a184e2c57dd152e6f4)
Linux : Check if trashing loadavg=$(
Bash Kilobytes to Gigs: echo 58427328 |awk '{$1=$1/(1024^2); print $1,"GB";}'
take a thread dump kill -3
check which services are running on which run level chkconfig --list
kb to gigs echo 58427328 |awk '{$1=$1/(1024^2); print $1,"GB";}'
total mem in gbs cat /proc/meminfo | awk 'NR==1' | awk -F ' ' '{printf("%d\n",$2)}' |awk '{$1=$1/(1024^2); print $1,"GB";}'
DELETE FIRST N CHARACTERS IN A FILE :%s/^.\{n}/
vi turn off highlighting :nohlsearch
vi regex delete :g/profile/d
grep with file name grep -H, --with-filename Print the file name for each match. This is the default when there is more than one file to search.
cool find with grep find . -name '*jinit' -type f -follow -exec grep -H "ettinger" {} \; 2>/dev/null
cool find with grep find . -type f -follow -name "*log*" -prune -o -exec grep -H "UBSA" {} \; 2>/dev/null >UBSA.txt
find apache find / -name 2>/dev/null
an bash for loop command line example for i in `cat dservers`; do ssh -q $i "hostname;whoami"; done
linux dictionary find /usr/share/dict/
vim delete first n character in every line :%s/^.\{4}//g
egrep egrep 'pap|bap' text | wc -l
another i for loop example for i in `cat rhosts`; do ypcat hosts | grep $i| grep ion ;done
loop for i in `ls | grep ROUTER`; do grep -r 'CPUAvg {0.[5-7].}' $i/LOGS/* ;done | awk -F "/" '{print $1}' | uniq
bash test user myvariable=$(whoami) echo $myvariable
find file exclude delete find -type f \( ! -iname "*.bz2" \) -exec rm {} \;
Swappiness Swappiness is a Linux kernel parameter that controls the relative weight given to swapping out runtime memory, as opposed to dropping pages from the system page cache. Swappiness can be set to values between 0 and 100 inclusive.
part 2 : /proc/sys/vm/swappiness A low value causes the kernel to avoid swapping, a higher value causes the kernel to try to use swap space.
Part3 The default value is 60, and for most desktop systems, setting it to 100 may affect the overall performance, whereas setting it lower (even 0) may decrease response latency
for loop with a compare and ypcat for i in `cat irs_users`; do printf "$i, ";ypcat passwd | grep $i; printf "\n" ; done
next date date -d "next day" '+%m/%d/%Y'
local disk size df -h --total
swap size swapon -s
total memory in use percentage free | grep Mem | awk '{print ($3+$6)/$2 * 100.0}'
change in text file sed -i 's/xusemsprod1/xusionprod006/g' tibemsd.conf
grep / for for i in `cat host_delete.09212016`;do grep $i hosts.txt ;done
sed / for for i in `cat host_delete.09212016`;do sed -i '/$i/d' hosts.txt ;done
The command inserts a tag to the beginning of a file: sed -i "1s/^/<?php /" file
command inserts a tag to the end of a file: echo "xstm0141vpap" >>hosts.txt
ILO Connection
scp a folder scp -r target destination
awk/cut example ps aux | grep -i ion| grep -v migration | grep -v grep | grep "lx" |awk -F " " '{print $13}' | cut -c 45-75
test broken link if [[ -L tradeweb ]] && [[ -a "/home/castanmc/pub" ]];then echo "Broken";else echo "OK"; fi
find dir and return complete path find -name "0" -exec readlink -f {} \;
RHEL where to put a nice alias .bashrc eg alias q="rlwrap q"
find min/max port range /proc/sys/net/ipv4/ip_local_port_range
|| executes RHS iff LHS is executed and doesn't have a ) return value
&& Evaluates the RHS if LHS is true.
clear all history history -c
Clear a specific line/command archived in your history output history -d 131
this will display a process (family) tree ps ef (no -)
find zombie processes ps aux | awk '"[Zz]" ~ $8 { printf("%s, PID = %d\n", $8, $2); }'
find and kill zombies ps axu | awk '"[Zz]" ~ $8 { system(sprintf("kill -HUP %d", $2)); }'
lists the available signal names and the corresponding numbers kill -l
get Zombie process (parent id) ps aux | awk '"[Zz]" ~ $8 { system("ps -o ppid=" $2);}'
orphan process is a user process, which is having init (process id - 1) as parent
find with complete path find `pwd` -name file.txt
vim copy y
return value of a lamba 101h
tmux:split horizontally control b and shift %
tmux: split vertically control b and shift "
tmux:toggle control b and all arrows
tmux: resize windows control b , hold shift , and arrows
pftp psftp> lpwd Current local directory is C:\Users\castanedam\Desktop
add settings permanently to vim create .vimrc say set mouse=
awk: system cmd only returns status
awk: to get system output "whoami" | getline username
ps: l l is multi-threaded (using CLONE_THREAD, like NPTL pthreads do)
ps:s s is a session leader
ps:S S Interruptible sleep (waiting for an event to complete
xxd converts to hex
vim: word wrap :wrap!
check every file in a dir find . type f -exec cksum {} \;
tee example wc -l | tee file.txt
make diff -y (side by side) columns bigger alias diff='diff -W $(( $(tput cols) - 2 ))'
search rlwrap control R
vim path pwd from inside vim :!pwd
vim write another file location :w /path/path2
bash: ctrl + l clear
bash:ctrl + u delete character up the cursor
bash:ctrl + k delete chaaracters after the cursor
Bash: ctrk + f/b move one work up or down.
create a directory tree mkdir -p
dirname strip non-directory suffix from file name.
readlink print value of a symbolic link or canonical file name.
declare permit modifying the properties of variables
declare -a means that it will be treated as an array
tm${tm/ /0} replaces the first open space and replaces it with a 0
create a large file dd if=/dev/zero of=output.dat bs=1M count=24
How big is the folder du -hc 2017.04.19 | grep total
rsync copy links but not what they point to. rsync -avl
sym link ln -s /path/to/file /path/to/symlink
Check for broken link; it returns broken links. find -L . -type l
vi: show pwd+file :echo expand("%")
Get History from line x to y history| awk '{if ($1>1600 && $1<1835) {print $0}}'
vim delete after a character :g/:/norm nD
vim : upper or lower case ctl ~
count string delimitated $head -n 1 sys.cfg |grep -o ";" | wc -l
ulimit open process grep -iR "Max open" /proc/68919 2>/dev/null
find port from pid $netstat -ltp | grep 31051
show historical mem usuage in sar sar -r -f /var/log/sa/sa10
saw usage for i in `ls -ltrh /var/log/sa/sa[0-9]* | awk -F " " '{print $9}'`; do sar -r -f $i |grep "02:40:01 PM" | awk -F " " '{print $5}'; done
vim delete between quotes di"
biggest files du -hs /banktools/teamquest/* | sort -rh | head -5 2>/dev/null
Created by: topbeagle