{"id":634,"date":"2012-07-10T16:43:55","date_gmt":"2012-07-10T08:43:55","guid":{"rendered":"http:\/\/rmohan.com\/?p=634"},"modified":"2012-07-10T16:44:08","modified_gmt":"2012-07-10T08:44:08","slug":"my-loveable-linux-commands","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=634","title":{"rendered":"My Loveable Linux Commands"},"content":{"rendered":"<p><strong>My Loveable Linux Commands<\/strong><br \/>\n<strong>Command\u00a0\u00a0 \u00a0Description<\/strong><\/p>\n<p>apropos whatis\u00a0\u00a0 \u00a0Show commands pertinent to string See also threadsafe<br \/>\nman -t ascii | ps2pdf &#8211; &gt; asciipdf\u00a0\u00a0 \u00a0make a pdf of a manual page<br \/>\nwhich command\u00a0\u00a0 \u00a0Show full path name of command<br \/>\ntime command\u00a0\u00a0 \u00a0See how long a command takes<br \/>\ntime cat\u00a0\u00a0 \u00a0Start stopwatch Ctrl-d to stop See also sw<\/p>\n<p><strong>Dir navigation<\/strong><\/p>\n<p>cd &#8211;\u00a0\u00a0 \u00a0Go to previous directory<br \/>\ncd\u00a0\u00a0 \u00a0Go to $HOME directory<br \/>\n(cd dir &amp;&amp; command)\u00a0\u00a0 \u00a0Go to dir, execute command and return to current dir<br \/>\npushd \u00a0\u00a0 \u00a0Put current dir on stack so you can popd back to it<\/p>\n<p><strong>File searching<\/strong><\/p>\n<p>alias l=&#8217;ls -l &#8211;color=auto&#8217;\u00a0\u00a0 \u00a0quick dir listing<br \/>\nls -lrt\u00a0\u00a0 \u00a0List files by date See also newest and find_mm_yyyy<br \/>\nls \/usr\/bin | pr -T9 -W$COLUMNS\u00a0\u00a0 \u00a0Print in 9 columns to width of terminal<br \/>\nfind -name &#8216;*[ch]&#8217; | xargs grep -E &#8216;expr&#8217;\u00a0\u00a0 \u00a0Search &#8216;expr&#8217; in this dir and below See also findrepo<br \/>\nfind -type f -print0 | xargs -r0 grep -F &#8216;example&#8217;\u00a0\u00a0 \u00a0Search all regular files for &#8216;example&#8217; in this dir and below<br \/>\nfind -maxdepth 1 -type f | xargs grep -F &#8216;example&#8217;\u00a0\u00a0 \u00a0Search all regular files for &#8216;example&#8217; in this dir<br \/>\nfind -maxdepth 1 -type d | while read dir; do echo $dir; echo cmd2; done\u00a0\u00a0 \u00a0Process each item with multiple commands (in while loop)<br \/>\nfind -type f ! -perm -444\u00a0\u00a0 \u00a0Find files not readable by all (useful for web site)<br \/>\nfind -type d ! -perm -111\u00a0\u00a0 \u00a0Find dirs not accessible by all (useful for web site)<br \/>\nlocate -r &#8216;file[^\/]*\\txt&#8217;\u00a0\u00a0 \u00a0Search cached index for names This re is like glob *file*txt<br \/>\nlook reference\u00a0\u00a0 \u00a0Quickly search (sorted) dictionary for prefix<br \/>\ngrep &#8211;color reference \/usr\/share\/dict\/words\u00a0\u00a0 \u00a0Highlight occurances of regular expression in dictionary<\/p>\n<p><strong>Archives and compression<\/strong><\/p>\n<p>gpg -c file\u00a0\u00a0 \u00a0Encrypt file<br \/>\ngpg filegpg\u00a0\u00a0 \u00a0Decrypt file<br \/>\ntar -c dir\/ | bzip2 &gt; dirtarbz2\u00a0\u00a0 \u00a0Make compressed archive of dir\/<br \/>\nbzip2 -dc dirtarbz2 | tar -x\u00a0\u00a0 \u00a0Extract archive (use gzip instead of bzip2 for targz files)<br \/>\ntar -c dir\/ | gzip | gpg -c | ssh user@remote &#8216;dd of=dirtargzgpg&#8217;\u00a0\u00a0 \u00a0Make encrypted archive of dir\/ on remote machine<br \/>\nfind dir\/ -name &#8216;*txt&#8217; | tar -c &#8211;files-from=- | bzip2 &gt; dir_txttarbz2\u00a0\u00a0 \u00a0Make archive of subset of dir\/ and below<br \/>\nfind dir\/ -name &#8216;*txt&#8217; | xargs cp -a &#8211;target-directory=dir_txt\/ &#8211;parents\u00a0\u00a0 \u00a0Make copy of subset of dir\/ and below<br \/>\n( tar -c \/dir\/to\/copy ) | ( cd \/where\/to\/ &amp;&amp; tar -x -p )\u00a0\u00a0 \u00a0Copy (with permissions) copy\/ dir to \/where\/to\/ dir<br \/>\n( cd \/dir\/to\/copy &amp;&amp; tar -c\u00a0 ) | ( cd \/where\/to\/ &amp;&amp; tar -x -p )\u00a0\u00a0 \u00a0Copy (with permissions) contents of copy\/ dir to \/where\/to\/<br \/>\n( tar -c \/dir\/to\/copy ) | ssh -C user@remote &#8216;cd \/where\/to\/ &amp;&amp; tar -x -p&#8217;\u00a0\u00a0 \u00a0Copy (with permissions) copy\/ dir to remote:\/where\/to\/ dir<br \/>\ndd bs=1M if=\/dev\/sda | gzip | ssh user@remote &#8216;dd of=sdagz&#8217;\u00a0\u00a0 \u00a0Backup harddisk to remote machine<\/p>\n<p><strong>rsync (Network efficient file copier: Use the &#8211;dry-run option for testing)<\/strong><\/p>\n<p>rsync -P rsync:\/\/rsyncservercom\/path\/to\/file file\u00a0\u00a0 \u00a0Only get diffs Do multiple times for troublesome downloads<br \/>\nrsync &#8211;bwlimit=1000 fromfile tofile\u00a0\u00a0 \u00a0Locally copy with rate limit It&#8217;s like nice for I\/O<br \/>\nrsync -az -e ssh &#8211;delete ~\/public_html\/ remotecom:&#8217;~\/public_html&#8217;\u00a0\u00a0 \u00a0Mirror web site (using compression and encryption)<br \/>\nrsync -auz -e ssh remote:\/dir\/\u00a0 &amp;&amp; rsync -auz -e ssh\u00a0 remote:\/dir\/\u00a0\u00a0 \u00a0Synchronize current directory with remote one<\/p>\n<p><strong>ssh (Secure SHell)<\/strong><\/p>\n<p>ssh $USER@$HOST command\u00a0\u00a0 \u00a0Run command on $HOST as $USER (default command=shell)<br \/>\nssh -f -Y $USER@$HOSTNAME xeyes\u00a0\u00a0 \u00a0Run GUI command on $HOSTNAME as $USER<br \/>\nscp -p -r $USER@$HOST: file dir\/\u00a0\u00a0 \u00a0Copy with permissions to $USER&#8217;s home directory on $HOST<br \/>\nscp -c arcfour $USER@$LANHOST: bigfile\u00a0\u00a0 \u00a0Use faster crypto for local LAN This might saturate GigE<br \/>\nssh -g -L 8080:localhost:80 root@$HOST\u00a0\u00a0 \u00a0Forward connections to $HOSTNAME:8080 out to $HOST:80<br \/>\nssh -R 1434:imap:143 root@$HOST\u00a0\u00a0 \u00a0Forward connections from $HOST:1434 in to imap:143<br \/>\nssh-copy-id $USER@$HOST\u00a0\u00a0 \u00a0Install public key for $USER@$HOST for password-less log in<\/p>\n<p><strong>wget (multi purpose download tool)<\/strong><\/p>\n<p>(cd dir\/ &amp;&amp; wget -nd -pHEKk http:\/\/wwwpixelbeatorg\/cmdlinehtml)\u00a0\u00a0 \u00a0Store local browsable version of a page to the current dir<br \/>\nwget -c http:\/\/wwwexamplecom\/largefile\u00a0\u00a0 \u00a0Continue downloading a partially downloaded file<br \/>\nwget -r -nd -np -l1 -A &#8216;*jpg&#8217; http:\/\/wwwexamplecom\/dir\/\u00a0\u00a0 \u00a0Download a set of files to the current directory<br \/>\nwget [url]ftp:\/\/remote\/file[\/url][1-9]iso\/\u00a0\u00a0 \u00a0FTP supports globbing directly<br \/>\nwget -q -O- http:\/\/wwwpixelbeatorg\/timelinehtml | grep &#8216;a href&#8217; | head\u00a0\u00a0 \u00a0Process output directly<br \/>\necho &#8216;wget url&#8217; | at 01:00\u00a0\u00a0 \u00a0Download url at 1AM to current dir<br \/>\nwget &#8211;limit-rate=20k url\u00a0\u00a0 \u00a0Do a low priority download (limit to 20KB\/s in this case)<br \/>\nwget -nv &#8211;spider &#8211;force-html -i bookmarkshtml\u00a0\u00a0 \u00a0Check links in a file<br \/>\nwget &#8211;mirror http:\/\/wwwexamplecom\/\u00a0\u00a0 \u00a0Efficiently update a local copy of a site (handy from cron)<\/p>\n<p><strong>Networking (Note ifconfig, route, mii-tool, nslookup commands are obsolete)<\/strong><\/p>\n<p>ethtool eth0\u00a0\u00a0 \u00a0Show status of ethernet interface eth0<br \/>\nethtool &#8211;change eth0 autoneg off speed 100 duplex full\u00a0\u00a0 \u00a0Manually set ethernet interface speed<br \/>\niwconfig eth1\u00a0\u00a0 \u00a0Show status of wireless interface eth1<br \/>\niwconfig eth1 rate 1Mb\/s fixed\u00a0\u00a0 \u00a0Manually set wireless interface speed<br \/>\niwlist scan\u00a0\u00a0 \u00a0List wireless networks in range<br \/>\nip link show\u00a0\u00a0 \u00a0List network interfaces<br \/>\nip link set dev eth0 name wan\u00a0\u00a0 \u00a0Rename interface eth0 to wan<br \/>\nip link set dev eth0 up\u00a0\u00a0 \u00a0Bring interface eth0 up (or down)<br \/>\nip addr show\u00a0\u00a0 \u00a0List addresses for interfaces<br \/>\nip addr add 1234\/24 brd + dev eth0\u00a0\u00a0 \u00a0Add (or del) ip and mask (2552552550)<br \/>\nip route show\u00a0\u00a0 \u00a0List routing table<br \/>\nip route add default via 123254\u00a0\u00a0 \u00a0Set default gateway to 123254<br \/>\nhost pixelbeatorg\u00a0\u00a0 \u00a0Lookup DNS ip address for name or vice versa<br \/>\nhostname -i\u00a0\u00a0 \u00a0Lookup local ip address (equivalent to host `hostname`)<br \/>\nwhois pixelbeatorg\u00a0\u00a0 \u00a0Lookup whois info for hostname or ip address<br \/>\nnetstat -tupl\u00a0\u00a0 \u00a0List internet services on a system<br \/>\nnetstat -tup\u00a0\u00a0 \u00a0List active connections to\/from system<\/p>\n<p><strong>windows networking (Note samba is the package that provides all this windows specific networking support)<\/strong><\/p>\n<p>smbtree\u00a0\u00a0 \u00a0Find windows machines See also findsmb<br \/>\nnmblookup -A 1234\u00a0\u00a0 \u00a0Find the windows (netbios) name associated with ip address<br \/>\nsmbclient -L windows_box\u00a0\u00a0 \u00a0List shares on windows machine or samba server<br \/>\nmount -t smbfs -o fmask=666,guest \/\/windows_box\/share \/mnt\/share\u00a0\u00a0 \u00a0Mount a windows share<br \/>\necho &#8216;message&#8217; | smbclient -M windows_box\u00a0\u00a0 \u00a0Send popup to windows machine (off by default in XP sp2)<\/p>\n<p><strong>Text manipulation (Note sed uses stdin and stdout Newer versions support inplace editing with the -i option)<\/strong><\/p>\n<p>sed &#8216;s\/string1\/string2\/g&#8217;\u00a0\u00a0 \u00a0Replace string1 with string2<br \/>\nsed &#8216;s\/\\(*\\)1\/\\12\/g&#8217;\u00a0\u00a0 \u00a0Modify anystring1 to anystring2<br \/>\nsed &#8216;\/ *#\/d; \/^ *$\/d&#8217;\u00a0\u00a0 \u00a0Remove comments and blank lines<br \/>\nsed &#8216;:a; \/\\\\$\/N; s\/\\\\\\n\/\/; ta&#8217;\u00a0\u00a0 \u00a0Concatenate lines with trailing \\<br \/>\nsed &#8216;s\/[ \\t]*$\/\/&#8217;\u00a0\u00a0 \u00a0Remove trailing spaces from lines<br \/>\nsed &#8216;s\/\\([`&#8221;$\\]\\)\/\\\\\\1\/g&#8217;\u00a0\u00a0 \u00a0Escape shell metacharacters active within double quotes<br \/>\nseq 10 | sed &#8220;s\/^\/\u00a0\u00a0\u00a0\u00a0\u00a0 \/; s\/ *\\(\\{7,\\}\\)\/\\1\/&#8221;\u00a0\u00a0 \u00a0Right align numbers<br \/>\nsed -n &#8216;1000{p;q}&#8217;\u00a0\u00a0 \u00a0Print 1000th line<br \/>\nsed -n &#8216;10,20p;20q&#8217;\u00a0\u00a0 \u00a0Print lines 10 to 20<br \/>\nsed -n &#8216;s\/*&lt;title&gt;\\(*\\)&lt;\\\/title&gt;*\/\\1\/ip;T;q&#8217;\u00a0\u00a0 \u00a0Extract title from HTML web page<br \/>\nsed -i 42d ~\/ssh\/known_hosts\u00a0\u00a0 \u00a0Delete a particular line<br \/>\nsort -t -k1,1n -k2,2n -k3,3n -k4,4n\u00a0\u00a0 \u00a0Sort IPV4 ip addresses<br \/>\necho &#8216;Test&#8217; | tr &#8216;[:lower:]&#8217; &#8216;[:upper:]&#8217;\u00a0\u00a0 \u00a0Case conversion<br \/>\ntr -dc &#8216;[:print:]&#8217; &lt; \/dev\/urandom\u00a0\u00a0 \u00a0Filter non printable characters<br \/>\ntr -s &#8216;[:blank:]&#8217; &#8216;\\t&#8217; &lt;\/proc\/diskstats | cut -f4\u00a0\u00a0 \u00a0cut fields separated by blanks<br \/>\nhistory | wc -l\u00a0\u00a0 \u00a0Count lines<\/p>\n<p><strong>set operations (Note you can export LANG=C for speed Also these assume no duplicate lines within a file)<\/strong><br \/>\nsort file1 file2 | uniq\u00a0\u00a0 \u00a0Union of unsorted files<br \/>\nsort file1 file2 | uniq -d\u00a0\u00a0 \u00a0Intersection of unsorted files<br \/>\nsort file1 file1 file2 | uniq -u\u00a0\u00a0 \u00a0Difference of unsorted files<br \/>\nsort file1 file2 | uniq -u\u00a0\u00a0 \u00a0Symmetric Difference of unsorted files<br \/>\njoin -t&#8217;\\0&#8242; -a1 -a2 file1 file2\u00a0\u00a0 \u00a0Union of sorted files<br \/>\njoin -t&#8217;\\0&#8242; file1 file2\u00a0\u00a0 \u00a0Intersection of sorted files<br \/>\njoin -t&#8217;\\0&#8242; -v2 file1 file2\u00a0\u00a0 \u00a0Difference of sorted files<br \/>\njoin -t&#8217;\\0&#8242; -v1 -v2 file1 file2\u00a0\u00a0 \u00a0Symmetric Difference of sorted files<\/p>\n<p><strong>math<\/strong><br \/>\necho &#8216;(1 + sqrt(5))\/2&#8217; | bc -l\u00a0\u00a0 \u00a0Quick math (Calculate ?) See also bc<br \/>\nseq -f &#8216;4\/%g&#8217; 1 2 99999 | paste -sd-+ | bc -l\u00a0\u00a0 \u00a0Calculate ? the unix way<br \/>\necho &#8216;pad=20; min=64; (100*10^6)\/((pad+min)*8)&#8217; | bc\u00a0\u00a0 \u00a0More complex (int) eg This shows max FastE packet rate<br \/>\necho &#8216;pad=20; min=64; print (100E6)\/((pad+min)*8)&#8217; | python\u00a0\u00a0 \u00a0Python handles scientific notation<br \/>\necho &#8216;pad=20; plot [64:1518] (100*10**6)\/((pad+x)*8)&#8217; | gnuplot -persist\u00a0\u00a0 \u00a0Plot FastE packet rate vs packet size<br \/>\necho &#8216;obase=16; ibase=10; 64206&#8217; | bc\u00a0\u00a0 \u00a0Base conversion (decimal to hexadecimal)<br \/>\necho $((0x2dec))\u00a0\u00a0 \u00a0Base conversion (hex to dec) ((shell arithmetic expansion))<br \/>\nunits -t &#8216;100m\/958s&#8217; &#8216;miles\/hour&#8217;\u00a0\u00a0 \u00a0Unit conversion (metric to imperial)<br \/>\nunits -t &#8216;500GB&#8217; &#8216;GiB&#8217;\u00a0\u00a0 \u00a0Unit conversion (SI to IEC prefixes)<br \/>\nunits -t &#8216;1 googol&#8217;\u00a0\u00a0 \u00a0Definition lookup<br \/>\nseq 100 | (tr &#8216;\\n&#8217; +; echo 0) | bc\u00a0\u00a0 \u00a0Add a column of numbers See also add and funcpy<\/p>\n<p><strong>calendar<\/strong><br \/>\ncal -3\u00a0\u00a0 \u00a0Display a calendar<br \/>\ncal 9 1752\u00a0\u00a0 \u00a0Display a calendar for a particular month year<br \/>\ndate -d fri\u00a0\u00a0 \u00a0What date is it this friday See also day<br \/>\n[ $(date -d &#8217;12:00 +1 day&#8217; +%d) = &#8217;01&#8217; ] || exit\u00a0\u00a0 \u00a0exit a script unless it&#8217;s the last day of the month<br \/>\ndate &#8211;date=&#8217;25 Dec&#8217; +%A\u00a0\u00a0 \u00a0What day does xmas fall on, this year<br \/>\ndate &#8211;date=&#8217;@2147483647&#8242;\u00a0\u00a0 \u00a0Convert seconds since the epoch (1970-01-01 UTC) to date<br \/>\nTZ=&#8217;America\/Los_Angeles&#8217; date\u00a0\u00a0 \u00a0What time is it on west coast of US (use tzselect to find TZ)<br \/>\ndate &#8211;date=&#8217;TZ=&#8221;America\/Los_Angeles&#8221; 09:00 next Fri&#8217;\u00a0\u00a0 \u00a0What&#8217;s the local time for 9AM next Friday on west coast US<\/p>\n<p><strong>locales<\/strong><\/p>\n<p>printf &#8220;%&#8217;d\\n&#8221; 1234\u00a0\u00a0 \u00a0Print number with thousands grouping appropriate to locale<br \/>\nBLOCK_SIZE=\\&#8217;1 ls -l\u00a0\u00a0 \u00a0Use locale thousands grouping in ls See also l<br \/>\necho &#8220;I live in `locale territory`&#8221;\u00a0\u00a0 \u00a0Extract info from locale database<br \/>\nLANG=en_IEutf8 locale int_prefix\u00a0\u00a0 \u00a0Lookup locale info for specific country See also ccodes<br \/>\nlocale -kc $(locale | sed -n &#8216;s\/\\(LC_\\{4,\\}\\)=*\/\\1\/p&#8217;) | less\u00a0\u00a0 \u00a0List fields available in locale database<\/p>\n<p><strong>recode (Obsoletes iconv, dos2unix, unix2dos)<\/strong><\/p>\n<p>recode -l | less\u00a0\u00a0 \u00a0Show available conversions (aliases on each line)<br \/>\nrecode windows-1252 file_to_changetxt\u00a0\u00a0 \u00a0Windows &#8220;ansi&#8221; to local charset (auto does CRLF conversion)<br \/>\nrecode utf-8\/CRLF file_to_changetxt\u00a0\u00a0 \u00a0Windows utf8 to local charset<br \/>\nrecode iso-8859-15utf8 file_to_changetxt\u00a0\u00a0 \u00a0Latin9 (western europe) to utf8<br \/>\nrecode \/b64 &lt; filetxt &gt; fileb64\u00a0\u00a0 \u00a0Base64 encode<br \/>\nrecode \/qp &lt; fileqp &gt; filetxt\u00a0\u00a0 \u00a0Quoted printable decode<br \/>\nrecode HTML &lt; filetxt &gt; filehtml\u00a0\u00a0 \u00a0Text to HTML<br \/>\nrecode -lf windows-1252 | grep euro\u00a0\u00a0 \u00a0Lookup table of characters<br \/>\necho -n 0x80 | recode latin-9\/x1dump\u00a0\u00a0 \u00a0Show what a code represents in latin-9 charmap<br \/>\necho -n 0x20AC | recode ucs-2\/x2latin-9\/x\u00a0\u00a0 \u00a0Show latin-9 encoding<br \/>\necho -n 0x20AC | recode ucs-2\/x2utf-8\/x\u00a0\u00a0 \u00a0Show utf-8 encoding<br \/>\n<strong>CDs<\/strong><br \/>\ngzip &lt; \/dev\/cdrom &gt; cdromisogz\u00a0\u00a0 \u00a0Save copy of data cdrom<br \/>\nmkisofs -V LABEL -r dir | gzip &gt; cdromisogz\u00a0\u00a0 \u00a0Create cdrom image from contents of dir<br \/>\nmount -o loop cdromiso \/mnt\/dir\u00a0\u00a0 \u00a0Mount the cdrom image at \/mnt\/dir (read only)<br \/>\ncdrecord -v dev=\/dev\/cdrom blank=fast\u00a0\u00a0 \u00a0Clear a CDRW<br \/>\ngzip -dc cdromisogz | cdrecord -v dev=\/dev\/cdrom &#8211;\u00a0\u00a0 \u00a0Burn cdrom image (use dev=ATAPI -scanbus to confirm dev)<br \/>\ncdparanoia -B\u00a0\u00a0 \u00a0Rip audio tracks from CD to wav files in current dir<br \/>\ncdrecord -v dev=\/dev\/cdrom -audio -pad *wav\u00a0\u00a0 \u00a0Make audio CD from all wavs in current dir (see also cdrdao)<br \/>\noggenc &#8211;tracknum=&#8217;track&#8217; trackcddawav -o &#8216;trackogg&#8217;\u00a0\u00a0 \u00a0Make ogg file from wav file<\/p>\n<p><strong>disk space (See also FSlint)<\/strong><\/p>\n<p>ls -lSr\u00a0\u00a0 \u00a0Show files by size, biggest last<br \/>\ndu -s * | sort -k1,1rn | head\u00a0\u00a0 \u00a0Show top disk users in current dir See also dutop<br \/>\ndu -hs \/home\/* | sort -k1,1h\u00a0\u00a0 \u00a0Sort paths by easy to interpret disk usage<br \/>\ndf -h\u00a0\u00a0 \u00a0Show free space on mounted filesystems<br \/>\ndf -i\u00a0\u00a0 \u00a0Show free inodes on mounted filesystems<br \/>\nfdisk -l\u00a0\u00a0 \u00a0Show disks partitions sizes and types (run as root)<br \/>\nrpm -q -a &#8211;qf &#8216;%10{SIZE}\\t%{NAME}\\n&#8217; | sort -k1,1n\u00a0\u00a0 \u00a0List all packages by installed size (Bytes) on rpm distros<br \/>\ndpkg-query -W -f=&#8217;${Installed-Size;10}\\t${Package}\\n&#8217; | sort -k1,1n\u00a0\u00a0 \u00a0List all packages by installed size (KBytes) on deb distros<br \/>\ndd bs=1 seek=2TB if=\/dev\/null of=ext3test\u00a0\u00a0 \u00a0Create a large test file (taking no space) See also truncate<br \/>\n&gt; file\u00a0\u00a0 \u00a0truncate data of file or create an empty file<\/p>\n<p><strong>monitoring\/debugging<\/strong><\/p>\n<p>tail -f \/var\/log\/messages\u00a0\u00a0 \u00a0Monitor messages in a log file<br \/>\nstrace -c ls &gt;\/dev\/null\u00a0\u00a0 \u00a0Summarise\/profile system calls made by command<br \/>\nstrace -f -e open ls &gt;\/dev\/null\u00a0\u00a0 \u00a0List system calls made by command<br \/>\nstrace -f -e trace=write -e write=1,2 ls &gt;\/dev\/null\u00a0\u00a0 \u00a0Monitor what&#8217;s written to stdout and stderr<br \/>\nltrace -f -e getenv ls &gt;\/dev\/null\u00a0\u00a0 \u00a0List library calls made by command<br \/>\nlsof -p $$\u00a0\u00a0 \u00a0List paths that process id has open<br \/>\nlsof ~\u00a0\u00a0 \u00a0List processes that have specified path open<br \/>\ntcpdump not port 22\u00a0\u00a0 \u00a0Show network traffic except ssh See also tcpdump_not_me<\/p>\n<p>ps -e -o pid,args &#8211;forest\u00a0\u00a0 \u00a0List processes in a hierarchy<br \/>\nps -e -o pcpu,cpu,nice,state,cputime,args &#8211;sort pcpu | sed &#8216;\/^ 00 \/d&#8217;\u00a0\u00a0 \u00a0List processes by % cpu usage<br \/>\nps -e -orss=,args= | sort -b -k1,1n | pr -TW$COLUMNS\u00a0\u00a0 \u00a0List processes by mem (KB) usage See also ps_mempy<br \/>\nps -C firefox-bin -L -o pid,tid,pcpu,state\u00a0\u00a0 \u00a0List all threads for a particular process<br \/>\nps -p 1,$$ -o etime=\u00a0\u00a0 \u00a0List elapsed wall time for particular process IDs<\/p>\n<p>last reboot\u00a0\u00a0 \u00a0Show system reboot history<\/p>\n<p>free -m\u00a0\u00a0 \u00a0Show amount of (remaining) RAM (-m displays in MB)<br \/>\nwatch -n1 &#8216;cat \/proc\/interrupts&#8217;\u00a0\u00a0 \u00a0Watch changeable data continuously<br \/>\nudevadm monitor\u00a0\u00a0 \u00a0Monitor udev events to help configure rules<\/p>\n<p><strong>System information (see also sysinfo) (&#8216;#&#8217; means root access is required)<\/strong><\/p>\n<p>uname -a\u00a0\u00a0 \u00a0Show kernel version and system architecture<br \/>\nhead -n1 \/etc\/issue\u00a0\u00a0 \u00a0Show name and version of distribution<br \/>\ncat \/proc\/partitions\u00a0\u00a0 \u00a0Show all partitions registered on the system<br \/>\ngrep MemTotal \/proc\/meminfo\u00a0\u00a0 \u00a0Show RAM total seen by the system<br \/>\ngrep &#8220;model name&#8221; \/proc\/cpuinfo\u00a0\u00a0 \u00a0Show CPU(s) info<br \/>\nlspci -tv\u00a0\u00a0 \u00a0Show PCI info<br \/>\nlsusb -tv\u00a0\u00a0 \u00a0Show USB info<br \/>\nmount | column -t\u00a0\u00a0 \u00a0List mounted filesystems on the system (and align output)<br \/>\ngrep -F capacity: \/proc\/acpi\/battery\/BAT0\/info\u00a0\u00a0 \u00a0Show state of cells in laptop battery<\/p>\n<p>#\u00a0\u00a0 \u00a0dmidecode -q | less\u00a0\u00a0 \u00a0Display SMBIOS\/DMI information<br \/>\n#\u00a0\u00a0 \u00a0smartctl -A \/dev\/sda | grep Power_On_Hours\u00a0\u00a0 \u00a0How long has this disk (system) been powered on in total<br \/>\n#\u00a0\u00a0 \u00a0hdparm -i \/dev\/sda\u00a0\u00a0 \u00a0Show info about disk sda<br \/>\n#\u00a0\u00a0 \u00a0hdparm -tT \/dev\/sda\u00a0\u00a0 \u00a0Do a read speed test on disk sda<br \/>\n#\u00a0\u00a0 \u00a0badblocks -s \/dev\/sda\u00a0\u00a0 \u00a0Test for unreadable blocks on disk sda<\/p>\n<p><strong>Interactive (see also linux keyboard shortcuts)<\/strong><\/p>\n<p>readline\u00a0\u00a0 \u00a0Line editor used by bash, python, bc, gnuplot,<br \/>\nscreen\u00a0\u00a0 \u00a0Virtual terminals with detach capability,<br \/>\nmc\u00a0\u00a0 \u00a0Powerful file manager that can browse rpm, tar, ftp, ssh,<br \/>\ngnuplot\u00a0\u00a0 \u00a0Interactive\/scriptable graphing<br \/>\nlinks\u00a0\u00a0 \u00a0Web browser<br \/>\nxdg-open \u00a0\u00a0 \u00a0open a file or url with the registered desktop application<\/p>\n","protected":false},"excerpt":{"rendered":"<p>My Loveable Linux Commands Command Description<\/p>\n<p>apropos whatis Show commands pertinent to string See also threadsafe man -t ascii | ps2pdf &#8211; &gt; asciipdf make a pdf of a manual page which command Show full path name of command time command See how long a command takes time cat Start stopwatch Ctrl-d to stop See [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/634"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=634"}],"version-history":[{"count":2,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/634\/revisions"}],"predecessor-version":[{"id":636,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/634\/revisions\/636"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=634"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=634"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=634"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}