{"id":10122,"date":"2015-09-24T03:00:55","date_gmt":"2015-09-24T02:00:55","guid":{"rendered":"https:\/\/stevepedwards.today\/DebianAdmin\/?p=10122"},"modified":"2023-11-01T03:01:28","modified_gmt":"2023-11-01T03:01:28","slug":"some-linux-one-line-cmds","status":"publish","type":"post","link":"https:\/\/stevepedwards.today\/DebianAdmin\/some-linux-one-line-cmds\/","title":{"rendered":"Some Linux One Line Cmds"},"content":{"rendered":"<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_10122\" class=\"pvc_stats all  \" data-element-id=\"10122\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n<p><span style=\"color: #0000ff;\">lsblk<\/span><br \/>\n<span style=\"color: #ff0000;\">NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT<\/span><br \/>\n<span style=\"color: #ff0000;\">sda 8:0 0 1.4T 0 disk <\/span><br \/>\n<span style=\"color: #ff0000;\">\/dev\/sda1 8:1 0 1.4T 0 part \/1500GB<\/span><br \/>\n<span style=\"color: #ff0000;\">sdb 8:16 0 931.5G 0 disk <\/span><br \/>\n<span style=\"color: #ff0000;\">\/dev\/sdb1 8:17 0 931.5G 0 part \/Quadra<\/span><br \/>\n<span style=\"color: #ff0000;\">sdc 8:32 0 149.1G 0 disk <\/span><br \/>\n<span style=\"color: #ff0000;\">\u00e2\u201d\u00e2\u201d\u20acsdc1 8:33 0 142.6G 0 part \/<\/span><br \/>\n<span style=\"color: #ff0000;\">\u00e2\u201d\u00e2\u201d\u20acsdc2 8:34 0 1K 0 part <\/span><br \/>\n<span style=\"color: #ff0000;\">\/dev\/sdc5 8:37 0 6.5G 0 part [SWAP]<\/span><br \/>\n<span style=\"color: #ff0000;\">sdd 8:48 0 931.5G 0 disk <\/span><br \/>\n<span style=\"color: #ff0000;\">\/dev\/sdd1 8:49 0 931.5G 0 part \/Storebird<\/span><\/p>\n<p>Always forget how to spell certain words? Look uses the dictionary unless other arg given:<\/p>\n<p><span style=\"color: #0000ff;\">look nece<\/span><br \/>\n<span style=\"color: #ff0000;\">necessaries<\/span><br \/>\n<span style=\"color: #ff0000;\">necessarily<\/span><br \/>\n<span style=\"color: #ff0000;\">necessary<\/span><br \/>\n<span style=\"color: #ff0000;\">necessary's<\/span><br \/>\n<span style=\"color: #ff0000;\">necessitate<\/span><br \/>\n<span style=\"color: #ff0000;\">necessitated<\/span><br \/>\n<span style=\"color: #ff0000;\">necessitates<\/span><br \/>\n<span style=\"color: #ff0000;\">necessitating<\/span><br \/>\n<span style=\"color: #ff0000;\">necessities<\/span><br \/>\n<span style=\"color: #ff0000;\">necessity<\/span><br \/>\n<span style=\"color: #ff0000;\">necessity's<\/span><\/p>\n<p>I don't know if \"find\" can find file <em><strong>types<\/strong><\/em>; So I just created a handy line for removing various\u00a0text files so you can be selective - or any <strong><em>type<\/em><\/strong> that the <span style=\"color: #0000ff;\">file<\/span> command recognises - probably better ways to do it, but the fun of linux tools is creating your own step by step that work for you! Rewarding! I needed to remove lots of *txt files, some of which are empty. It <strong><em>lists the file types; greps key word; prints\u00a0only column 1 with colon; removes the colon; runs rm for that filename.\u00a0<\/em><\/strong><\/p>\n<p><span style=\"color: #0000ff;\">file *txt<br \/>\n<span style=\"color: #ff0000;\">bobtest.txt: empty <\/span><br \/>\n<span style=\"color: #ff0000;\">fileA.txt: empty <\/span><br \/>\n<span style=\"color: #ff0000;\">fileB.txt: empty <\/span><br \/>\n<span style=\"color: #ff0000;\">fileC.txt: empty <\/span><br \/>\n<span style=\"color: #ff0000;\">gaussian.txt: ASCII text<\/span><br \/>\n<span style=\"color: #ff0000;\">histlist.txt: UTF-8 Unicode text<\/span><br \/>\n<span style=\"color: #ff0000;\">perflist.txt: ASCII text<\/span><br \/>\n<span style=\"color: #ff0000;\">random.txt: ASCII text<\/span><br \/>\n<span style=\"color: #ff0000;\">wlan.txt: ASCII text<\/span><\/span><\/p>\n<p><span style=\"color: #0000ff;\">file * | grep <strong>empty<\/strong> | awk '{print $1}' | sed s\/:\/\/g | xargs rm -v<\/span><\/p>\n<p>To remove the others, replace type (empty, ASCII, UTF, or just \"text\" will cover them etc), after grep.<\/p>\n<p>You can\u00a0remove all in first go, grep txt. obviously, or just :<\/p>\n<p><span style=\"color: #0000ff;\">rm -v *txt<\/span><\/p>\n<p>but that doesn't give a chance to check them as a wrongly named file\/other of other type, so could be a big mistake.<\/p>\n<p>Delete all local mail:<\/p>\n<p><span style=\"color: #ff0000;\">Held 7 messages in \/var\/mail\/stevee<\/span><br \/>\nstevee@AMD ~ $ <span style=\"color: #0000ff;\">mail<\/span><\/p>\n<p><span style=\"color: #ff0000;\">U 7 Cron Daemon Sat Aug 13 00:30 23\/1034 Cron &lt;stevee@AMD&gt; rsync -<\/span><br \/>\n<strong><span style=\"color: #ff0000;\">? d*<\/span><\/strong><br \/>\n<span style=\"color: #ff0000;\">? q<\/span><\/p>\n<p><span style=\"color: #ffffff;\">From Linux Server Hacks, if you have created \/home\/user\/bin, then it should be added to your $PATH for your own scripts due to .profile<\/span> :<\/p>\n<p><span style=\"color: #0000ff;\"><span style=\"color: #ff0000;\"># set PATH so it includes user's private bin if it exists<\/span><br \/>\n<span style=\"color: #ff0000;\">if [ -d \"$HOME\/bin\" ] ; then<\/span><br \/>\n<span style=\"color: #ff0000;\"> PATH=\"$HOME\/bin:$PATH\"<\/span><\/span><\/p>\n<p><span style=\"color: #0000ff;\"><span style=\"color: #ffffff;\">create this disk usage alias by adding it to your .bash_aliases so retained on reboot:<\/span><br \/>\nalias ducks='du -cks * | sort -rn | head -11'<\/span><\/p>\n<p><span style=\"color: #ffffff;\">now cd to any dir, and run it - if you want -h, it wont show largest files in hi-low order as M is above G:<\/span><\/p>\n<p><span style=\"color: #0000ff;\">ducks<br \/>\n<\/span><span style=\"color: #ff0000;\">54191636 total<\/span><br \/>\n<span style=\"color: #ff0000;\">43135152 Videos<\/span><br \/>\n<span style=\"color: #ff0000;\">10894868 Downloads<\/span><br \/>\n<span style=\"color: #ff0000;\">107972 Documents<\/span><br \/>\n<span style=\"color: #ff0000;\">45568 Desktop<\/span><br \/>\n<span style=\"color: #ff0000;\">6396 Pictures<\/span><br \/>\n<span style=\"color: #ff0000;\">1644 Cprogs<\/span><br \/>\n<span style=\"color: #ff0000;\">20 Music<\/span><br \/>\n<span style=\"color: #ff0000;\">12 bin<\/span><br \/>\n<span style=\"color: #ff0000;\">4 setuid.txt<\/span><\/p>\n<p>only way round G\/M size for du is set the blocksize to your biggest file size units, e.g. -BG for Gig size files e.g.:<\/p>\n<p><span style=\"color: #0000ff;\">du -BG \/Storebird\/Vids\/ | sort -nr | head -5<\/span><br \/>\n<span style=\"color: #ff0000;\">135G \/Storebird\/Vids\/<\/span><br \/>\n<span style=\"color: #ff0000;\">29G \/Storebird\/Vids\/Cosmos<\/span><br \/>\n<span style=\"color: #ff0000;\">17G \/Storebird\/Vids\/DavidIcke<\/span><br \/>\n<span style=\"color: #ff0000;\">10G \/Storebird\/Vids\/MadMcann<\/span><br \/>\n<span style=\"color: #ff0000;\">9G \/Storebird\/Vids\/DavidIcke\/Icke-FeedomRd<\/span><\/p>\n<p>so, alias BIGducks!<\/p>\n<p><span style=\"color: #0000ff;\"> vi .bash_aliases<\/span><br \/>\nstevee@AMD ~ $<span style=\"color: #0000ff;\"> alias BIGducks='du -cBG * | sort -nr | head -11'<\/span><br \/>\nstevee@AMD ~ $ <span style=\"color: #0000ff;\">BIGducks<\/span><br \/>\n<span style=\"color: #ff0000;\">52G total<\/span><br \/>\n<span style=\"color: #ff0000;\">42G Videos<\/span><br \/>\n<span style=\"color: #ff0000;\">11G Downloads<\/span><br \/>\n<span style=\"color: #ff0000;\">1G Videos\/screencasts<\/span><br \/>\n<span style=\"color: #ff0000;\">1G setuid.txt<\/span><br \/>\n<span style=\"color: #ff0000;\">1G Pictures\/screenshots<\/span><br \/>\n<span style=\"color: #ff0000;\">1G Pictures<\/span><br \/>\n<span style=\"color: #ff0000;\">1G Music<\/span><br \/>\n<span style=\"color: #ff0000;\">1G Downloads\/VirtualRadar\/zh-CN<\/span><br \/>\n<span style=\"color: #ff0000;\">1G Downloads\/VirtualRadar\/Web\/script\/vrs<\/span><br \/>\n<span style=\"color: #ff0000;\">1G Downloads\/VirtualRadar\/Web\/script\/jquiplugin<\/span><\/p>\n<p>Find setuid a=s files with:<\/p>\n<p><span style=\"color: #0000ff;\">sudo find \/usr\/bin\/ -perm +6000 -type f -exec ls -ld {} +; &gt; setuid.txt<\/span><\/p>\n<p><span style=\"color: #0000ff;\">sudo find \/usr\/bin\/ -perm +a=s -type f<\/span><\/p>\n<p><span style=\"color: #ffffff;\">change file's mod time:<\/span><\/p>\n<p><span style=\"color: #0000ff;\">touch -d \"Jun 22 18:03\" file.txt<\/span><\/p>\n<p>This did a good job of recovering lost files to \/tmp\/recover from a Sportcam SDcard that was DD'd to\u00a0lizard.img:<\/p>\n<p><span style=\"color: #0000ff;\">photorec \/d \/tmp\/recover \/cmd lizard.img partition_none,options,fileopt,everything,enable,search<\/span><\/p>\n<p>History Expansion<\/p>\n<p>The shell offers a specialized type of expansion for items in the history list by using the<br \/>\n! character. We have already seen how the exclamation point can be followed by a<br \/>\nnumber to insert an entry from the history list. There are a number of other expansion fea-<br \/>\ntures:<br \/>\nTable 8-6: History Expansion Commands<br \/>\nSequence Action<br \/>\n!! Repeat the last command. It is probably easier to press up arrow and<br \/>\nenter.<br \/>\n!number Repeat history list item number.<br \/>\n!string Repeat last history list item starting with string.<br \/>\n<span style=\"color: #ff0000;\"><em><strong>!?string Repeat last history list item containing string. Fab!!<\/strong><\/em><\/span><br \/>\nI would caution against using the !string and !?string forms unless you are absolutely<br \/>\nsure of the contents of the history list items.<\/p>\n<p><span style=\"color: #0000ff;\">!?nbt<\/span><br \/>\n<span style=\"color: #ff0000;\">nbtscan 192.168.1.1-254<\/span><br \/>\n<span style=\"color: #ff0000;\">Doing NBT name scan for addresses from 192.168.1.1-254<\/span><\/p>\n<p><span style=\"color: #ff0000;\">IP address NetBIOS Name Server User MAC address <\/span><br \/>\n<span style=\"color: #ff0000;\">----<\/span><br \/>\n<span style=\"color: #ff0000;\">192.168.1.16 AMD &lt;server&gt; AMD 00:00:00:00:00:00<\/span><br \/>\n<span style=\"color: #ff0000;\">192.168.1.10 DELLMINT &lt;server&gt; DELLMINT 00:00:00:00:00:00<\/span><br \/>\n<span style=\"color: #ff0000;\">192.168.1.11 HPMINT &lt;server&gt; HPMINT 00:00:00:00:00:00<\/span><br \/>\n<span style=\"color: #ff0000;\">192.168.1.216 PIBLANC &lt;server&gt; PIBLANC 00:00:00:00:00:00<\/span><br \/>\n<span style=\"color: #ff0000;\">192.168.1.212 SOUTH &lt;server&gt; SOUTH 00:00:00:00:00:00<\/span><br \/>\n<span style=\"color: #ff0000;\">192.168.1.213 PINOIR &lt;server&gt; PINOIR 00:00:00:00:00:00<\/span><br \/>\n<span style=\"color: #ff0000;\">192.168.1.217 PIFRONT &lt;server&gt; PIFRONT 00:00:00:00:00:00<\/span><\/p>\n<p><strong>Passwords<\/strong><\/p>\n<p>user can change own pword as setuid bit is set to root for this command, so user becomes root while it runs:<\/p>\n<p><span style=\"color: #0000ff;\">ls -al \/usr\/bin\/passwd<\/span><br \/>\n<span style=\"color: #ff0000;\">-rw<strong>s<\/strong>r-xr-x 1 root root 47032 Jul 15 20:29 \/usr\/bin\/passwd<\/span><\/p>\n<p><span style=\"color: #0000ff;\">passwd -h<\/span><\/p>\n<p><span style=\"color: #ff0000;\">Options:<\/span><br \/>\n<span style=\"color: #ff0000;\"> -a, --all report password status on all accounts (not in Mint!)<\/span><br \/>\n<span style=\"color: #ff0000;\"> -d, --delete delete the password for the named account<\/span><br \/>\n<span style=\"color: #ff0000;\"> -e, --expire force expire the password for the named account<\/span><br \/>\n<span style=\"color: #ff0000;\"> -h, --help display this help message and exit<\/span><br \/>\n<span style=\"color: #ff0000;\"> -k, --keep-tokens change password only if expired<\/span><br \/>\n<span style=\"color: #ff0000;\"> -i, --inactive INACTIVE set password inactive after expiration<\/span><br \/>\n<span style=\"color: #ff0000;\"> to INACTIVE<\/span><br \/>\n<span style=\"color: #ff0000;\"> -l, --lock lock the password of the named account<\/span><br \/>\n<span style=\"color: #ff0000;\"> -n, --mindays MIN_DAYS set minimum number of days before password<\/span><br \/>\n<span style=\"color: #ff0000;\"> change to MIN_DAYS<\/span><br \/>\n<span style=\"color: #ff0000;\"> -q, --quiet quiet mode<\/span><br \/>\n<span style=\"color: #ff0000;\"> -r, --repository REPOSITORY change password in REPOSITORY repository<\/span><br \/>\n<span style=\"color: #ff0000;\"> -R, --root CHROOT_DIR directory to chroot into<\/span><br \/>\n<span style=\"color: #ff0000;\"> -S, --status report password status on the named account<\/span><br \/>\n<span style=\"color: #ff0000;\"> -u, --unlock unlock the password of the named account<\/span><br \/>\n<span style=\"color: #ff0000;\"> -w, --warndays WARN_DAYS set expiration warning days to WARN_DAYS<\/span><br \/>\n<span style=\"color: #ff0000;\">-x, --maxdays MAX_DAYS set maximum number of days before password<\/span><br \/>\n<span style=\"color: #ff0000;\"> change to MAX_DAYS<\/span><\/p>\n<p><strong>Find only first 10 real users unames in \/etc\/passwd (Mint)<\/strong><\/p>\n<p>Real (non system) users start at grp no. 1000, so sorting unames in \/etc\/passwd by group number 1000-1009 using grep, with 4th char, NOT \":\" to remove group 100: = user libuuid<\/p>\n<p>Just \"100.\" gives groups containing 100. so no good<\/p>\n<p>DELLMINT stevee # <span style=\"color: #0000ff;\">cat \/etc\/passwd | sort | grep\u00a0100.<\/span><br \/>\n<span style=\"color: #ff0000;\">bill:x:1002:1001:,,,:\/home\/bill:\/bin\/bash<\/span><br \/>\n<span style=\"color: #ff0000;\">eng:x:1001:1001:,,,:\/home\/eng:\/bin\/bash<\/span><br \/>\n<span style=\"color: #ff0000;\">joe:x:1003:1002:,,,:\/home\/joe:\/bin\/bash<\/span><br \/>\n<strong><span style=\"color: #ff0000;\">libuuid:x:100:101::\/var\/lib\/libuuid:<\/span><\/strong><\/p>\n<p>so add 100.[:]<\/p>\n<p><span style=\"color: #0000ff;\">cat \/etc\/passwd | grep 100.[:]<\/span><br \/>\n<span style=\"color: #ff0000;\">stevee:x:1000:1000:stevee,,,:\/home\/stevee:\/bin\/bash<\/span><br \/>\n<span style=\"color: #ff0000;\">geddylee:x:1001:1001:,,,:\/home\/geddylee:\/bin\/bash<\/span><\/p>\n<p>or of course:<\/p>\n<p><span style=\"color: #0000ff;\">cat \/etc\/passwd | sort | grep 100[0-9]<\/span><\/p>\n<p>(find blank lines and\/or how many in a file, using the \"anchors\" - the start and end of line chars - which every line MUST have!<\/p>\n<p><span style=\"color: #0000ff;\">grep '^$' file.txt | wc -l<\/span><\/p>\n<p><strong>Blank Line Stripper<\/strong><\/p>\n<p>Use that with sed to delete (d)\u00a0the blank lines from a file:<\/p>\n<p>stevee@Mint5630 ~\/Documents\/SEDAWK $ <span style=\"color: #0000ff;\">grep '^.*$' books<\/span><br \/>\n<span style=\"color: #ff0000;\">Here are the books that you requested<\/span><\/p>\n<p><span style=\"color: #ff0000;\">Yes, it is a good book for children<\/span><\/p>\n<p><span style=\"color: #ff0000;\">It is amazing to think that it was called a \"harmful book\"<\/span><\/p>\n<p><span style=\"color: #ff0000;\">when<\/span><br \/>\n<span style=\"color: #ff0000;\">once you get to the end of the book, you can't believe<\/span><br \/>\nstevee@Mint5630 ~\/Documents\/SEDAWK $ <span style=\"color: #0000ff;\">grep '^.*$' books | sed '\/^$\/d'<\/span><br \/>\n<span style=\"color: #ff0000;\">Here are the books that you requested<\/span><br \/>\n<span style=\"color: #ff0000;\">Yes, it is a good book for children<\/span><br \/>\n<span style=\"color: #ff0000;\">It is amazing to think that it was called a \"harmful book\"<\/span><br \/>\n<span style=\"color: #ff0000;\">when<\/span><br \/>\n<span style=\"color: #ff0000;\">once you get to the end of the book, you can't believe<\/span><\/p>\n<p>Or awk using a sed type search method:<\/p>\n<p><span style=\"color: #0000ff;\">awk '\/100.[:]\/' \/etc\/passwd<\/span><\/p>\n<p>All users starting with a\"b\"<\/p>\n<p><span style=\"color: #0000ff;\">\u00a0awk '\/^b\/' \/etc\/passwd<\/span><\/p>\n<p><span style=\"color: #ff0000;\">bin:x:2:2:bin:\/bin:\/usr\/sbin\/nologin<\/span><br \/>\n<span style=\"color: #ff0000;\">backup:x:34:34:backup:\/var\/backups:\/usr\/sbin\/nologin<\/span><br \/>\n<span style=\"color: #ff0000;\">bill:x:1002:1002:,,,:\/home\/bill:\/bin\/bash<\/span><\/p>\n<p><b>3Copy an MBR<\/b><\/p>\n<p>Use: # <span style=\"color: #0000ff;\">dd if=\/dev\/sda of=\/mbr bs=512 count=1<\/span><\/p>\n<p>to copy and...<\/p>\n<p>Use: # <span style=\"color: #0000ff;\">dd if=\/mbr of=\/dev\/hda bs=1 count=64 skip=446 seek=446<\/span><\/p>\n<p>to write it back<\/p>\n<p>This is the WinNT cmd line for dd-0.5 that copies from the unmounted hidden partition0 on a Vista pc:<\/p>\n<p>dd.exe if=\\\\?\\Device\\Harddisk0\\Partition0 of=\\\\.\\d:\/mbr bs=512 count=1<\/p>\n<p>DYNDNS<\/p>\n<p><span style=\"color: #0000ff;\">ddclient -query<\/span><\/p>\n<p>Learn VIM!!! Or another non-X windows text editor like Nano etc.<\/p>\n<p><span style=\"color: #0000ff;\">apt-get install vim<\/span><\/p>\n<p><span style=\"color: #0000ff;\">vimtutor<\/span><\/p>\n<p>You can open a file at specific word using # vi +\/\"word\" \/file.txt or at a line number<\/p>\n<p><span style=\"color: #0000ff;\">vi +30 \/webmin-setup.out<\/span><\/p>\n<p><span style=\"color: #0000ff;\">cat -n \/xpkgs.txt (adds line numbers to file contents)<\/span><\/p>\n<p><span style=\"color: #0000ff;\">arp -a<\/span><\/p>\n<p><span style=\"color: #0000ff;\">hdparm -i \/dev\/hda - gives all info on device:<\/span><\/p>\n<p><span style=\"color: #0000ff;\">finger username<\/span><\/p>\n<p><span style=\"color: #0000ff;\">apt-get install bwm-ng<\/span> (bandwidth monitor)<\/p>\n<p><span style=\"color: #0000ff;\">grpck<\/span> - checks group files integrity:<\/p>\n<p><span style=\"color: #0000ff;\">blkid \/dev\/sda1<\/span> find what filesystem is on a partition<\/p>\n<p><span style=\"color: #0000ff;\">less \/proc\/net\/bonding\/bond0<\/span> info on bonded ethernet cards<\/p>\n<p><span style=\"color: #0000ff;\">rsync --dry-run -e ssh --verbose --progress --stats --compress --recursive --times --perms --links --delete --exclude \"\/sys\" --exclude \"\/dev\" --exclude \"\/proc\" --exclude \"*bak\" \/* user@remoteserver.com:backupfolder<\/span><\/p>\n<p>(..Notice the --dry-run [-n] option to just test the transfer without actually sending files. It's a good idea to put this -n at the end of the line so you can delete it once you have dry-run and happy with what occurs!<\/p>\n<p>Note also the --delete option READ THE MAN PAGE FOR THESE OPTIONS - they may not do as you think. Finally note the -e ssh to ensure the transfer is actually secure. Once you are happy the process is working simple remove the -dry-run). So, a real practical net transfer command may be:<\/p>\n<p><span style=\"color: #0000ff;\">rsync -e ssh --verbose --progress --compress --recursive \u00a0\/home\/stevee\/Cprogs\/* stevee@dellmint:\/home\/stevee\/Cprogs\/<\/span><\/p>\n<p>which with recursive, archive mode, compression, human readable and visible progress\u00a0reduces to:<\/p>\n<p><span style=\"color: #0000ff;\">rsync -e ssh -vrazh --progress \/home\/stevee\/Cprogs\/* stevee@dellmint:\/home\/stevee\/Cprogs\/<\/span><\/p>\n<p><span style=\"color: #ff0000;\">Warning: the ECDSA host key for 'dellmint' differs from the key for the IP address '192.168.1.4'<\/span><br \/>\n<span style=\"color: #ff0000;\">Offending key for IP in \/home\/stevee\/.ssh\/known_hosts:1<\/span><br \/>\n<span style=\"color: #ff0000;\">Matching host key in \/home\/stevee\/.ssh\/known_hosts:12<\/span><br \/>\n<span style=\"color: #ff0000;\">Are you sure you want to continue connecting (yes\/no)? yes<\/span><br \/>\n<span style=\"color: #ff0000;\">stevee@dellmint's password: <\/span><br \/>\n<span style=\"color: #ff0000;\">sending incremental file list<\/span><br \/>\n<span style=\"color: #ff0000;\">RSYNCTEST.txt<\/span><br \/>\n<span style=\"color: #ff0000;\"> 0 100% 0.00kB\/s 0:00:00 (xfr#1, to-chk=138\/145)<\/span><\/p>\n<p><span style=\"color: #ff0000;\">sent 3.38K bytes received 37 bytes 402.47 bytes\/sec<\/span><br \/>\n<span style=\"color: #ff0000;\">total size is 627.17K speedup is 183.33<\/span><\/p>\n<p>If you wanted to delete the files at the other end that DON'T exist at the sending side to keep the send and receive sides identical say, use the\u00a0<strong><em>--delete-excluded <\/em><\/strong>option. BE SURE this is what you want! Files at the other end will be deleted - be sure you don't need them first if they don't exist on the sending side!!<\/p>\n<p><span style=\"color: #0000ff;\">du -ah \/LVM80G\/<\/span><\/p>\n<p><span style=\"color: #0000ff;\">df -h \/dev\/sda1<\/span><\/p>\n<p><span style=\"color: #0000ff;\">route add -net default gw x.x.x.x<\/span> (sets the default gateway for pc with static IP set via<\/p>\n<p><span style=\"color: #0000ff;\">ifconfig<\/span><\/p>\n<p>can be automated at boot by adding gateway=x.x.x.x to \/etc\/network\/interfaces file<\/p>\n<p><span style=\"color: #0000ff;\">grep $stg \/filename<\/span><\/p>\n<p><span style=\"color: #0000ff;\">ls -a \/Share\/ | grep \"^v\"<\/span> (find a file in \/share beginning with small \"v\")<\/p>\n<p><span style=\"color: #0000ff;\">ls -a \/Share\/ | grep \"^[^v]\"\u00a0<\/span>(find a file in \/Share NOT beginning with small \"v\" - NOTE diff meanings of ^ inside [ie NOT = ] or outside the []), ie ^=start of line.<\/p>\n<p>Like solving crosswords..? Use the \".\" for a single character match of 5 letter words starting with c and ending with h:<\/p>\n<p><span style=\"color: #0000ff;\">grep \"\\&lt;c...h\\&gt;\" \/usr\/share\/dict\/words<\/span><\/p>\n<p>You can also OP the contents of a whole file like using cat by finding ALL the chars in a file eg:<\/p>\n<p><span style=\"color: #0000ff;\">grep '.*' \/etc\/passwd<\/span><\/p>\n<p>or<\/p>\n<p><span style=\"color: #0000ff;\">awk '{print $0}' \/etc\/passwd<\/span><\/p>\n<p><span style=\"color: #ff0000;\">root:x:0:0:root:\/root:\/bin\/bash<\/span><\/p>\n<p><span style=\"color: #ff0000;\">daemon:x:1:1:daemon:\/usr\/sbin:\/bin\/sh<\/span><\/p>\n<p><span style=\"color: #ff0000;\">bin:x:2:2:bin:\/bin:\/bin\/sh<\/span><\/p>\n<p><span style=\"color: #ff0000;\">sys:x:3:3:sys:\/dev:\/bin\/sh<\/span><\/p>\n<p><span style=\"color: #ff0000;\">sync:x:4:65534:sync:\/bin:\/bin\/sync<\/span><\/p>\n<p><span style=\"color: #ff0000;\">games:x:5:60:games:\/usr\/games:\/bin\/sh<\/span><\/p>\n<p><span style=\"color: #ff0000;\">man:x:6:12:man:\/var\/cache\/man:\/bin\/sh<\/span><\/p>\n<p>...trunc...Also, my grep OP is colorised green for easy result view from editing the .bashrc file in home dir, and adding grep = grep -r as an alias, as other examples given<\/p>\n<p>DMESG (gives debug info of current startup events) and Notices<\/p>\n<p><span style=\"color: #0000ff;\">dmesg<\/span><\/p>\n<p>or can be read\/searched directly from file:<\/p>\n<p><span style=\"color: #0000ff;\">vi \/var\/log\/dmesg<\/span><\/p>\n<p>Edit <span style=\"color: #0000ff;\">\/etc\/syslog.conf<\/span> removing the # on the news, debug and notice \/dev\/tty8 lines as below to show system notices, like info on a newly plugged USB stick etc. Press Ctrl-Alt-F8 to see tty8.<\/p>\n<p><span style=\"color: #ff0000;\"># I like to have messages displayed on the console, but only on a virtual<\/span><\/p>\n<p><span style=\"color: #ff0000;\"># console I usually leave idle.<\/span><\/p>\n<p><span style=\"color: #ff0000;\">#daemon,mail.*;\\<\/span><\/p>\n<p><span style=\"color: #ff0000;\">news.=crit;news.=err;news.=notice;\\<\/span><\/p>\n<p><span style=\"color: #ff0000;\">*.=debug;*.=info;\\<\/span><\/p>\n<p><span style=\"color: #ff0000;\">*.=notice;*.=warn \/dev\/tty8<\/span><\/p>\n<p><span style=\"color: #0000ff;\">find . -type f -not -empty | wc -l<\/span><\/p>\n<p><span style=\"color: #0000ff;\">apropos find<\/span><\/p>\n<p><span style=\"color: #ff0000;\">chkdupexe (1) - find duplicate executables<\/span><\/p>\n<p><span style=\"color: #ff0000;\">dcopfind (1) - Find the DCOP reference of a KDE service<\/span><\/p>\n<p><span style=\"color: #ff0000;\">exinext (8) - Finding individual retry times<\/span><\/p>\n<p><span style=\"color: #ff0000;\">exiwhat (8) - Finding out what Exim processes are doing<\/span><\/p>\n<p><span style=\"color: #ff0000;\">find (1) - search for files in a directory hierarchy<\/span><\/p>\n<p><span style=\"color: #ff0000;\">find2perl (1) - translate find command lines to Perl code<\/span><\/p>\n<p><span style=\"color: #ff0000;\">findaffix (1) - Interactive spelling checking<\/span><\/p>\n<p><span style=\"color: #ff0000;\">findfs (8) - Find a filesystem by label or UUID<\/span><\/p>\n<p><span style=\"color: #ff0000;\">findsmb (1) - list info about machines that respond to SMB name queries on a subnet<\/span><\/p>\n<p><span style=\"color: #ff0000;\">gift (1) - GNU Image Finding Tool - index and search images by content<\/span><\/p>\n<p><span style=\"color: #ff0000;\">gift-add-collection.pl (1) - GNU Image Finding Tool - index and search images by content<\/span><\/p>\n<p><span style=\"color: #ff0000;\">gift-diagnose-print-all-ADI.pl (1) - GNU Image Finding Tool - index and search images by content<\/span><\/p>\n<p><span style=\"color: #ff0000;\">gift-dtd-to-keywords.pl (1) - GNU Image Finding Tool - index and search images by content<\/span><\/p>\n<p><span style=\"color: #ff0000;\">gift-dtd-to-tex.pl (1) - GNU Image Finding Tool - index and search images by content<\/span><\/p>\n<p><span style=\"color: #ff0000;\">gift-endianize (1) - GNU Image Finding Tool - index and search images by content<\/span><\/p>\n<p><span style=\"color: #ff0000;\">gift-extract-features (1) - GNU Image Finding Tool - index and search images by content<\/span><\/p>\n<p><span style=\"color: #ff0000;\">gift-generate-inverted-file (1) - GNU Image Finding Tool - index and search images by content<\/span><\/p>\n<p><span style=\"color: #ff0000;\">gift-modify-distance-matrix (1) - GNU Image Finding Tool - index and search images by content<\/span><\/p>\n<p><span style=\"color: #ff0000;\">gift-mrml-client.pl (1) - GNU Image Finding Tool - index and search images by content<\/span><\/p>\n<p><span style=\"color: #ff0000;\">gift-old-to-new-url2fts.pl (1) - GNU Image Finding Tool - index and search images by content<\/span><\/p>\n<p><span style=\"color: #ff0000;\">gift-one-minus (1) - GNU Image Finding Tool - index and search images by content<\/span><\/p>\n<p><span style=\"color: #ff0000;\">gift-perl-example-server.pl (1) - GNU Image Finding Tool - index and search images by content<\/span><\/p>\n<p><span style=\"color: #ff0000;\">gift-remove-collection.pl (1) - GNU Image Finding Tool - index and search images by content<\/span><\/p>\n<p><span style=\"color: #ff0000;\">gift-start.pl (1) - GNU Image Finding Tool - index and search images by content<\/span><\/p>\n<p><span style=\"color: #ff0000;\">gift-url-to-fts.pl (1) - GNU Image Finding Tool - index and search images by content<\/span><\/p>\n<p><span style=\"color: #ff0000;\">gift-write-feature-descs (1) - GNU Image Finding Tool - index and search images by content<\/span><\/p>\n<p><span style=\"color: #ff0000;\">gnuift (1) - GNU Image Finding Tool - index and search images by content<\/span><\/p>\n<p><span style=\"color: #ff0000;\">hal-find-by-capability (1) - find device objects by capability matching<\/span><\/p>\n<p><span style=\"color: #ff0000;\">hal-find-by-property (1) - find device objects by property matching<\/span><\/p>\n<p><span style=\"color: #ff0000;\">kappfinder (1) - searches for program to add to the Kde menu<\/span><\/p>\n<p><span style=\"color: #ff0000;\">kfind (1) - KDE find tool<\/span><\/p>\n<p><span style=\"color: #ff0000;\">locate (1) - find files by name<\/span><\/p>\n<p><span style=\"color: #ff0000;\">mlocate (1) - find files by name<\/span><\/p>\n<p><span style=\"color: #ff0000;\">oldfind (1) - search for files in a directory hierarchy<\/span><\/p>\n<p><span style=\"color: #ff0000;\">pidof (8) - find the process ID of a running program.<\/span><\/p>\n<p><span style=\"color: #ff0000;\">recursdir (1) - recurse through local or remote directories to command\/find files or create tar files.<\/span><\/p>\n<p><span style=\"color: #ff0000;\">runlevel (8) - find the previous and current system runlevel.<\/span><\/p>\n<p><span style=\"color: #ff0000;\">sane-find-scanner (1) - find SCSI and USB scanners and their device files<\/span><\/p>\n<p><span style=\"color: #0000ff;\">mount -t cifs \/\/server\/share \/dir -o username=user<\/span> (Note: this CIFS [Common Inet File Sys] format now supercedes SMBFS to mount a XP\/Vista share on Linbox via Samba. Note, Vista security requires Netcard having Netbios, port 139 enabled in Properties\/Advanced\/WINS tab)<\/p>\n<p><span style=\"color: #0000ff;\">netstat -an | grep ssh<\/span> (searches for string with particular number associated eg for seeing connection state info on a network service eg ssh\/apache2 service connected or listening, [also use # nmap 127.0.0.1] )<\/p>\n<p><span style=\"color: #0000ff;\">nmap -PO<\/span> x.x.x.x (uses varied pings to try penetrate a stealthed IP)<\/p>\n<p><span style=\"color: #0000ff;\">tcpdump -vv eth0<\/span> ( 2 Vs - puts netcard into promiscuous listening mode to view, Very Verbosely, bcast address info, e.g. to find a lost subnet addr on a preconfigured net device with no reset to default button)<\/p>\n<p><span style=\"color: #0000ff;\">socat<\/span> (netcat on steroids supposedly - look into this...)<\/p>\n<p><span style=\"color: #0000ff;\">socat - TCP:localhost:www,crnl<\/span> (fetches whole webpage.html after 2 way pipe is open and GET \/ typed)<\/p>\n<p><span style=\"color: #0000ff;\">GET \/<\/span><\/p>\n<p><span style=\"color: #0000ff;\">vim .bashrc<\/span> (edits user .bashrc file using vim editor to get colourisation for ls -al and grep listings etc.)<\/p>\n<p><span style=\"color: #0000ff;\">pwgen<\/span> (generates 8 digit passwords of varying complexity)<\/p>\n<p><span style=\"color: #0000ff;\">man pwgen<\/span> (manual page for program... if it exists..or try \"info\")<\/p>\n<p><span style=\"color: #0000ff;\">apt-get install linux-image*<\/span> (lists all available image names for current architecture, i386, or AMD64 etc. can search any packages using wildcard * like this also)<\/p>\n<p><span style=\"color: #0000ff;\">apt-get install knemo<\/span> (config via Control Panel for taskbar network icons and info)<\/p>\n<p><span style=\"color: #0000ff;\">apt-cache pkgnames | sort &gt; pkgs.txt<\/span> (outputs all the 30000 odd package names available for install on Debian, pipes output via sort to list them alphabetically, and saves list as a textfile)<\/p>\n<p><span style=\"color: #0000ff;\">apt-cache pkgnames | wc -l<\/span> (pipes packagenames via word count with a -l line switch to give a total count of all packages, = 30107 for this kernel version)<\/p>\n<p><span style=\"color: #0000ff;\">uname -a<\/span> (gives full kernel version info = Linux t5500 2.6.26-1-686 #1 SMP Thu Oct 9 15:18:09 UTC 2008 i686 GNU\/Linux)<\/p>\n<p><span style=\"color: #0000ff;\">scp ~\/.ssh\/id_rsa.pub username@remoteserver.com:.ssh\/auth_keys<\/span> (secure copy of public keys to remote server .ssh\/auth_keys file to enable passwordless logins\/transfers via rsync. ssh-keygen had to been run on remote and local fir dirs to exist to copy from\/to!) <strong>Mint does not allow ssh root logins, Raspbian still does 09\/2015<\/strong><\/p>\n<p><span style=\"color: #0000ff;\">ssh-keygen <span style=\"color: #ffffff;\">(default prompts)<\/span><\/span><\/p>\n<p><span style=\"color: #0000ff;\">ssh-keygen -t rsa -f \/etc\/ssh\/ssh_host_rsa_key<\/span><\/p>\n<p><span style=\"color: #0000ff;\">ssh-keygen -t dsa -f \/etc\/ssh\/ssh_host_dsa_key<\/span><\/p>\n<p>This below allows logging info from a Cisco\/WinServer to be logged by Debian in the enterprise.log. The Cisco IOS device has to be configd with:<\/p>\n<p><span style=\"color: #ff00ff;\">config term<\/span><\/p>\n<p><span style=\"color: #ff00ff;\">logging<\/span><\/p>\n<p><span style=\"color: #ff00ff;\">logging trap (3,4,7 level etc.)<\/span><\/p>\n<p><span style=\"color: #ff00ff;\">service timestamps log datetime<\/span><\/p>\n<p><span style=\"color: #ff00ff;\">logging on<\/span><\/p>\n<p>When done, stop the syslogd server with #\/etc\/init.d\/rsyslogd stop<\/p>\n<p>Restart with #\/etc\/ini.d\/rsyslogd restart (listens for remote log info.)<\/p>\n<p><span style=\"color: #0000ff;\">file \/pkgs.txt \/bin\/vdir<\/span> (tells file types of each file)<\/p>\n<p><span style=\"color: #0000ff;\">comm \/f1 \/f2<\/span> (compare two sorted files line by line)<\/p>\n<p><span style=\"color: #0000ff;\">cmp<\/span> - compare two files byte by byte<\/p>\n<p><span style=\"color: #0000ff;\">diff<\/span> (compare two files line by line)<\/p>\n<p><span style=\"color: #0000ff;\">uniq<\/span> (remove duplicate lines without changing original file)<\/p>\n<p><span style=\"color: #0000ff;\">ls -al \/bin\/ | wc -l<\/span> (the -l switch for wc is for \"lines\")<\/p>\n<p><span style=\"color: #0000ff;\">ls -alsh \/mnt\/<\/span><\/p>\n<p><span style=\"color: #0000ff;\">invoke<\/span> (alternative to \/etc\/init.d\/service start|stop|restart)<\/p>\n<p><span style=\"color: #0000ff;\">tar -xvf filename.tar<\/span> (recursively unpacks a tarball file)<\/p>\n<p>wpa_passphrase essid-name wpa-password &gt; \/etc\/wpa_supplicant\/wpa_supplicant.conf (creates a basic wpa conf file), then run:<\/p>\n<p>#wpa_supplicant -Dwext -iwlan0 -c\/etc\/wpa_supplicant\/wpa_supplicant.conf<\/p>\n<p>(where -D is the standard linux wireless extensions driver, wext; -i is the name of wifi card (wlan0, ath0 etc.); and -c is the conf file.)<\/p>\n<p>NOTE: a 10 digit hex password is a 40 bit secure psk; a 26 digit hex password eg \"abcdef1234abcdef1234abcdef\" is a 120 bit secure psk, and what can be input depends on the security capabilities of the ADSL wifi router\/modem<\/p>\n<p>Check yourself - run # <span style=\"color: #0000ff;\">wpa_passphrase linksys abcdef1234<\/span><\/p>\n<p>and you should get <span style=\"color: #ff0000;\">007aca04beffb195c12dee8a15682053f77f1342713af0d0e87db8141f4cbe86<\/span> as part of the output.<\/p>\n<p><span style=\"color: #0000ff;\">kill -9 pid<\/span> (pid = process ID, will terminate a locked running process, find (with grep) via<\/p>\n<p><span style=\"color: #0000ff;\">ps aux<\/span><\/p>\n<p><strong>Image Mounting<\/strong><\/p>\n<p><span style=\"color: #0000ff;\">mount -o loop \/share\/cruzer.img \/mnt\/<\/span> (mount an image file at \/mnt of a pendrive in the same way as an .iso file using the loop function - create initial .img file with<\/p>\n<p><span style=\"color: #0000ff;\">dd if=\/dev\/sdc1 of=\/share\/cruzer.img<\/span> - note that dd requires the device name not the mounted device folder name same as of=\/dev\/cdrom above)<\/p>\n<p><u><b>NETCAT<\/b><\/u><\/p>\n<p><span style=\"color: #0000ff;\">netcat -v -w 1 localhost -z 1-3000<\/span> (netcat as port scanner - initially found in \/etc\/alternatives\/netcat in Lenny, copy it to \/usr\/sbin)<\/p>\n<p>On Windows:<\/p>\n<p>g:\/nc.exe -lp 1337 &gt; file.zip (nc as ftp receiver on port 1377, pc B, listening)<\/p>\n<p>g:\/nc.exe -w 1 x.x.x.x_pc_A 1337 &lt; file.zip (netcat as ftp server now sending on port 1337, pcA to pcB \/ dir - COOL!!!. Ports close on end file transfer.)<\/p>\n<p>Using pv to give visual progress sending a file, first set listening\/receiving pc,<\/p>\n<p><span style=\"color: #0000ff;\">netcat -lp 4444 | pv | &gt; \/Efat32\/Vids\/Ivette.iso<\/span><\/p>\n<p><span style=\"color: #0000ff;\">cat \/iod\/Ivette\/Ivette.iso | pv | netcat 10.0.0.1 4444<\/span><\/p>\n<p><span style=\"color: #ff0000;\">3.06GB 0:05:49 [9.63MB\/s] [ &lt;=&gt; ]<\/span><\/p>\n<p>No auto EOF termination using cat (process not closing automatically) for file transfers that are ok up to 7.8GB<\/p>\n<p><b>Netcat Chat Server<\/b><\/p>\n<p>Have you ever needed an improvised one-on-one chat? Netcat can do that too. You simply start listening to connections on some port like this:<\/p>\n<p><span style=\"color: #0000ff;\">nc.exe -lp 1337<\/span> (Then on another machine simply connect to that port:)<\/p>\n<p><span style=\"color: #0000ff;\">nc.exe x.x.x.x_pcA 1337<\/span> (Now start typing on either machine. When you press enter, the line will immediately show up on the other machine)<\/p>\n<p><b>Netcat Telnet Server<\/b><\/p>\n<p>Netcat can also be used to set up a telnet server in a matter of seconds. You can specify the shell (or for that matter any executable) you want netcat to run at a successful connection with the -e parameter:<\/p>\n<p><span style=\"color: #0000ff;\">nc.exe -lp 1337 -e \/bin\/bash<\/span><\/p>\n<p>On windows you can use:<\/p>\n<p><span style=\"color: #0000ff;\">nc.exe -lp 1337 -e cmd.exe<\/span> (to run netcat on Vista, run cmd as Admin, cd to netcat dir, and add to anti-virus exceptions at pop up box. Run &gt;nc.exe -lp 1337 etc )<\/p>\n<p>Then on a client machine simply connect to port 1337 and you will get full access to the shell, with the permissions of the user who ran nc.exe on the Win server.<\/p>\n<p><b>Cloning Hard Drive Partitions Over the Network <\/b>(umounted partition required to write to remember, as dd writes to devices ONLY<\/p>\n<p>dd if=\/dev\/sda | netcat 192.168.0.1 9000<\/p>\n<p>netcat -l -p 9000 | dd of=\/dev\/sda<\/p>\n<p>Of course you need to have the cloned partitions unmounted on both systems. So if you are cloning \/ you will have to boot from a live distro like Knoppix. Note that you can use this technique to clone NTFS partitions as well - just need to use a live Linux distro on both sides.<\/p>\n<p><b>NTP port 123, SNTP port 583<\/b><\/p>\n<p>apt-get install ntp ntpdate (this will enable Net Time Prot sync for pc and will also server other pcs\/Cisco. When installed run<\/p>\n<p># ntpdate-debian to auto setup the local timeservers - EASY! Note the low end Cisco units only run SNTP but will still get time\/date from an NTP server: ntp server 131.188.3.223<\/p>\n<p><b>Partition Expansion<\/b><\/p>\n<p>Use gparted from bootable Rescue CD in a GUI<\/p>\n<p><b>Burn CD\/DVD with no GUI software<\/b><\/p>\n<p><span style=\"color: #0000ff;\">dd if=\/name.iso of=\/dev\/cdrom bs=1M<\/span><\/p>\n<p>or with wodim<\/p>\n<p>wodim \/file.iso (this is suficient to burn an iso to default cdrw device, auto found by wodim.<\/p>\n<p>Sparse files are files whose real allocation needs are fulfilled only when data are written inside them. If you try to read from places you haven't written before, you get zeroes - and these zeroes don't really occupy any space in your hard drive. If only one sector of data (512 bytes) gets written at some offset inside a sparse file, then a sector is all the sparse file will reserve from the file system - not the size reported by the file system!<\/p>\n<p>All that is required to create a 150GB sparse file under Windows is this: (From within a Cygwin command prompt) dd if=\/dev\/zero of=BigFile bs=1M count=1 seek=150000 This command will execute in 1 second, and it will only reserve 1MB of real hard drive space. Real storage will grow as needed, when data are written inside BigFile.<\/p>\n<p>Great trick to zero a hard drives emty space before zipping its contents as a backup file:<\/p>\n<p><span style=\"color: #0000ff;\">cat \/dev\/zero &gt; \/zero.fill<\/span><\/p>\n<p>This creates an emty file using all the drives remaining space, then delete it.<\/p>\n<p><span style=\"color: #0000ff;\">rm -v \/zero.fill<\/span><\/p>\n<p><span style=\"color: #0000ff;\">gzip \/ &gt; \/other_drive\/backup.gzip<\/span> (or bzip2 etc.)<\/p>\n<p>Compare before and after size with<\/p>\n<p><span style=\"color: #0000ff;\">du -h \/other_drive\/backup.gzip<\/span><\/p>\n<p><span style=\"color: #0000ff;\">gpart -W \/dev\/sdx \/dev\/sdx<\/span> (guess partitions and\/or backup\/re-write lost MBR [the -W switch] back to \/dev\/sdx after partitions have been guessed correctly - HOPEFULLY!)<\/p>\n<p><span style=\"color: #0000ff;\">host<\/span> is a simple utility for performing DNS lookups. It is normally<\/p>\n<p>used to convert names to IP addresses and vice versa. When no<\/p>\n<p>arguments or options are given, host prints a short summary of its<\/p>\n<p>command line arguments and options.<\/p>\n<p><span style=\"color: #0000ff;\">host 127.0.0.1<\/span><\/p>\n<p>1.0.0.127.in-addr.arpa domain name pointer Bthomehub.home.<\/p>\n<p><span style=\"color: #0000ff;\">host bbc.co.uk<\/span><\/p>\n<p><span style=\"color: #ff0000;\">bbc.co.uk has address 212.58.224.138.x<\/span><\/p>\n<p><span style=\"color: #ff0000;\">bbc.co.uk mail is handled by 10 cluster1.eu.messagelabs.com.<\/span><\/p>\n<p><span style=\"color: #ff0000;\">bbc.co.uk mail is handled by 20 cluster1a.eu.messagelabs.com.<\/span><\/p>\n<p><span style=\"color: #0000ff;\">host localhost<\/span><\/p>\n<p>localhost has address 69.175.20.250<\/p>\n<p>localhost mail is handled by 0 localhost.<\/p>\n<p><span style=\"color: #ffffff;\"><strong>Get user membership info:<\/strong><\/span><\/p>\n<p><span style=\"color: #0000ff;\">id stevee<\/span><\/p>\n<p><span style=\"color: #ff0000;\">uid=1000(stevee) gid=1000(stevee) groups=1000(stevee),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),108(lpadmin),110(sambashare)<\/span><\/p>\n<p>AMDA8 stevee #<span style=\"color: #0000ff;\"> id stevee -G<\/span><br \/>\n<span style=\"color: #ff0000;\">1000 4 24 27 30 46 108 110<\/span><br \/>\nAMDA8 stevee # <span style=\"color: #0000ff;\">cat \/etc\/group | grep stevee<\/span><br \/>\n<span style=\"color: #ff0000;\">adm:x:4:syslog,stevee<\/span><br \/>\n<span style=\"color: #ff0000;\">cdrom:x:24:stevee<\/span><br \/>\n<span style=\"color: #ff0000;\">sudo:x:27:stevee<\/span><br \/>\n<span style=\"color: #ff0000;\">dip:x:30:stevee<\/span><br \/>\n<span style=\"color: #ff0000;\">plugdev:x:46:stevee<\/span><br \/>\n<span style=\"color: #ff0000;\">lpadmin:x:108:stevee<\/span><br \/>\n<span style=\"color: #ff0000;\">sambashare:x:110:stevee<\/span><br \/>\n<span style=\"color: #ff0000;\">stevee:x:1000:<\/span><\/p>\n<p><span style=\"color: #0000ff;\">nl \/etc\/samba\/smb.conf<\/span><\/p>\n<p>numbers lines in a file and shows contents<\/p>\n<p><span style=\"color: #0000ff;\">reset<\/span> (resets terminal init to clear screen, same as<\/p>\n<p><span style=\"color: #0000ff;\">setterm -reset<\/span><\/p>\n<p><span style=\"font-size: 16; color: #0000ff;\">cat &gt; \/test.txt<\/span><\/p>\n<p><span style=\"color: #ff0000;\">text to go in this file<\/span>\u00a0(followed by Ctrl-D to close)<\/p>\n<p><span style=\"color: #0000ff;\">cat \/test.txt<\/span><\/p>\n<p><span style=\"color: #ff0000;\">text to go in this file<\/span><\/p>\n<p><span style=\"color: #0000ff;\">rev \/test.txt<\/span><\/p>\n<p><span style=\"color: #ff0000;\">tset rof txet<\/span><\/p>\n<p><span style=\"color: #0000ff;\">top<\/span> (shows running processes) q to quit<\/p>\n<p><span style=\"color: #0000ff;\">wall<\/span> (writes a msg to all users term windows [but not an Xwindow], end with Ctrl-D, or send file content: # wall &lt; \/file.txt)<\/p>\n<p><span style=\"color: #0000ff;\">tty<\/span><\/p>\n<p><span style=\"color: #0000ff;\">users<\/span> (shows all currently logged on users, except root session when root is logged in to SuperUserMode Terminal in X, only when in tty1-6 non X)<\/p>\n<p><span style=\"color: #ff0000;\">root stevee<\/span><\/p>\n<p><span style=\"color: #0000ff;\">w<\/span> (list all logged on users and their processes)<\/p>\n<p><span style=\"color: #0000ff;\">whereis java<\/span> (locates the binary, source, and manual page files for a command)<\/p>\n<p><span style=\"color: #ff0000;\">java: \/usr\/share\/java<\/span><\/p>\n<p><span style=\"color: #0000ff;\">0<\/span>\u00a0(bandwidth measuring app between 2 hosts- note 195.92.195.94 is the DNS of Orange uk and handy to remember for an alternate, and a web access\/ping test)<\/p>\n<p><b>Remove unused services at startup - eg Exim<\/b><\/p>\n<p>Services booting are found in \/etc\/rc*.d and can be prevented from starting by changing their name, and so the link to the binary eg:<\/p>\n<p>OLD! use: update-rc.d<\/p>\n<p># mv -v \/etc\/rc2.d\/S20exim \/etc\/rc2.d\/S_20exim<\/p>\n<p>#last stevee (this filters the contents of \/var\/log\/wtmp since the file was created, eg here filters info on user stevee<\/p>\n<p># lastlog<\/p>\n<p><b>MAIL<\/b><\/p>\n<p>Cmd line mail using SendEmail<\/p>\n<p>https:\/\/caspian.dotconf.net\/menu\/Software\/SendEmail\/<\/p>\n<p>apt-get install sendemail<\/p>\n<p>sendEmail -t stevepedwards@gmail.com -f joeblow@spoofed.com -cc stevepedwards@gmail.com -xu stevepedwards -xp password -s smtp.gmail.com:587<\/p>\n<p>No -m option takes text body from STDIN: firewall:~# sendEmail -f stevepedwards@gmail.com -t stevepedwards@gmail.com -u test -s smtp.gmail.com:587 -xu stevepedwards -xp password -m helo me<\/p>\n<p>Jun 28 23:15:49 firewall sendEmail[1575]: Email was sent successfully!<\/p>\n<p>Or pipe a file into the above eg:<\/p>\n<p>cat \/textfile.txt | sendEmail -t stevepedwards@gmail.com -f joeblow@spoofed.com -cc stevepedwards@gmail.com -xu stevepedwards -xp password -s smtp.gmail.com:587<\/p>\n<p>apt-get install chkconfig<\/p>\n<p>chkconfig --list | grep '3:on'<\/p>\n<p>#service apache2<\/p>\n<p>Delete All Mail Messages:<\/p>\n<p>#echo 'd *' | mail -N<\/p>\n<p>Delete All Mail Messages: For Any User<\/p>\n<p>#echo 'd *' | mail -N -u username<\/p>\n<p>Another way to use the mail command from the Linux CLI is to get information from a server and email it to yourself or someone else. For instance I may want to review a log file on another computer or have another systems administrator who may or may not have access to the server to view a log file. In the below example we will use the access.log file as an example Apache log that we want to email to ourselves so use the below command to do so.<\/p>\n<p># more \/file.txt | mail <a href=\"https:\/\/mail.google.com\/mail\/?view=cm&amp;fs=1&amp;tf=1&amp;to=user@example.com\" target=\"_blank\" rel=\"noopener\">user@example.com<\/a><\/p>\n<p>#socat SYSTEM:date -<\/p>\n<p>#date<\/p>\n<p>To change the system date use:<\/p>\n<p># date {mmddhhmiyyyy.ss}<\/p>\n<p>o mm Month<\/p>\n<p>o dd Date<\/p>\n<p>o hh 24 hour format<\/p>\n<p>o mi Minutes<\/p>\n<p>o yyyy Year<\/p>\n<p>o ss seconds<\/p>\n<p><strong>eg: to set system date to Jan 31st 2009, 10:19 p.m, 53 seconds<\/strong><\/p>\n<p><span style=\"color: #0000ff;\">date 013122192009.53<\/span><\/p>\n<p>To set the time only:<\/p>\n<p><span style=\"color: #0000ff;\">date +%T -s \"22:19:53\"<\/span><\/p>\n<p>Use hwclock without any parameter, to view the current hardware date and time:<\/p>\n<p><span style=\"color: #0000ff;\">hwclock<\/span><\/p>\n<p>set the hardware date and time based on the system date as shown below:<\/p>\n<p><span style=\"color: #0000ff;\">hwclock --systohc<\/span><\/p>\n<p><span style=\"color: #0000ff;\">hwclock --systohc --utc<\/span><\/p>\n<p><span style=\"color: #0000ff;\">date --date='360 days ago'<\/span> (can be seconds, minutes, months etc. ago)<\/p>\n<p>Sat Aug 16 20:24:18 CEST 2008<\/p>\n<p><strong>Show Future dates and Times\u00a0<\/strong><\/p>\n<p><span style=\"color: #0000ff;\">date --date=\"1 week\"<\/span> (can be sec, min, hour, day etc.)<\/p>\n<p>Tue Aug 18 20:28:24 CEST 2009<\/p>\n<p>Login to Remote Host using SSH<\/p>\n<p><span style=\"color: #0000ff;\">ssh -v 127.0.0.1<\/span> (shows debug info)<\/p>\n<p>To come back to the localhost temporarily, without logging out of remote ssh session, type the escape character (after editing \/etc\/ssh\/ssh_config and removing # from EscapeChar = ~): ~ and ^Z. When back to own console you can see the stopped session by running #<\/p>\n<p><span style=\"color: #0000ff;\">jobs<\/span><\/p>\n<p><span style=\"color: #0000ff;\">mount -o loop \/share\/iomegadeb.img \/mnt<\/span><\/p>\n<p>I fixed my \"too small\", application X font mismatch with HDMI TV resolution by adding this to xorg.conf:<\/p>\n<p>Option \"NoDDC\"<\/p>\n<p>to Section \"Device\"<\/p>\n<p>If the above change improves your system, but the result is less than 100% to your satisfaction, you can tweak sizes up or down by making the DisplaySize dimensions slightly larger or smaller than actual.<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_10122\" class=\"pvc_stats all  \" data-element-id=\"10122\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n<p>lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 1.4T 0 disk \/dev\/sda1 8:1 0 1.4T 0 part \/1500GB sdb 8:16 0 931.5G 0 disk \/dev\/sdb1 8:17 0 931.5G 0 part \/Quadra sdc 8:32 0 149.1G 0 disk \u00e2\u201d\u00e2\u201d\u20acsdc1 8:33 0 142.6G 0 part \/ \u00e2\u201d\u00e2\u201d\u20acsdc2 8:34 0 1K 0 part \/dev\/sdc5 8:37 <a href=\"https:\/\/stevepedwards.today\/DebianAdmin\/some-linux-one-line-cmds\/\" class=\"more-link\">...<span class=\"screen-reader-text\">\u00a0 Some Linux One Line Cmds<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-10122","post","type-post","status-publish","format-standard","hentry","category-post"],"a3_pvc":{"activated":true,"total_views":0,"today_views":0},"_links":{"self":[{"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/posts\/10122","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/comments?post=10122"}],"version-history":[{"count":1,"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/posts\/10122\/revisions"}],"predecessor-version":[{"id":10123,"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/posts\/10122\/revisions\/10123"}],"wp:attachment":[{"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/media?parent=10122"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/categories?post=10122"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/tags?post=10122"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}