linux mint IT admin tips info


A  Reminder Page for Future Study/Reference Links 

lspci -nn

07:00.0 VGA compatible controller [0300]: NVIDIA Corporation GF106 [GeForce GTS 450] [10de:0dc4] (rev a1)

lspci -d 10de:0dc4 -vvv

Kernel driver in use: nvidia


<meta name=viewport content="width=device-width, initial-scale=1">
to top of WP header.php file


Adding another apache server for your PiCams? - copy your current server's index.html to the current PC without shh, even though /var/www belongs to root:

wget dellmint:80; cat index.html | sudo tee /var/www/index.html

cat /var/www/index.html
<iframe src="" scrolling=no width=960 height=720 frameborder=no></iframe>....

If you re-install a PC, your ssh keys complain of threats etc. so remove and re-install them quickly:

ssh-keygen -R AMDA8
/home/stevee/.ssh/known_hosts updated.
Original contents retained as /home/stevee/.ssh/known_hosts.old

Get your external ip

dig +short

add it to an alias:



alias myip='dig +short'

add it permanently to .bash_aliases, and make sure your rsync includes .bash_aliases to other PCs for BU..

The sourceforge random corporate bullshit generator one liner:

sudo apt-get install curl

curl -s | grep -Eo '^<li>.*</li>' | sed s,\</\\?li\>,,g | shuf -n 1
The point is not merely to deploy an impetus. The point is to integrate promising client needs. The key people proactively promote under-the-radar dotted lines. Controlling should formulate a next-level emotional intelligence as a consequence of a robust cost reduction. The sales manager influences a present-day, profit-maximizing and impactful empowerment, while a fact-based value revolutionises requests / solutions.

Daft Script..

sudo apt-get install sysvbanner figlet

x=4; while expr $x>=2; do x=$(($x-1)); echo $x; echo "SYSFAULT X0:1 ScreenFault Pending..." ;sleep 1; done; banner SYSFAULT! | figlet

good metachar link:
at 0125 today
warning: commands will be executed using /bin/sh at> date at> xmessage -display :0.0 "You are late" at> <EOT> job 2 at Fri Aug 5 01:25:00 2016 xmsg.png

perl script to show PC name and top load avg in console window, when run:

perl bin/tl &

This is a good one to compare load avg values between the perl script values above:

python -c 'import os;print os.getloadavg()[0]; print os.getloadavg()[1]; print os.getloadavg()[2];'

Do this really quick with the up arrows:

stevee@AMDA8 ~ $ uptime
18:49:21 up 1:38, 4 users, load average: 2.29, 1.58, 1.21
stevee@AMDA8 ~ $ python -c 'import os;print os.getloadavg()[0]; print os.getloadavg()[1]; print os.getloadavg()[2];' | paste -s
2.29 1.58 1.21

!user/bin/perl -w
use Sys::Hostname;
use strict;
my $host = hostname;
chomp $host;

open(LOAD,"/proc/loadavg") || die "Could not open /proc/loadavg: $!\n";

my @load=split(/ /,<LOAD>);
close (LOAD);

print "\033]0;";
print "$host: $load[0] $load[1] $load[2] at ", scalar(localtime);
print "\007";

sleep 2;



make a perm alias in your home dir of those below:

alias budellmint='rsync -e ssh --progress /home/stevee/* stevee@dellmint:/home/stevee/ --exclude='.' --exclude=Videos --delete-excluded -vrah'

by creating, and adding it to what you have already e.g.:

vi .bash_aliases

alias BIGducks='du -cBG * | sort -nr | head -11'

alias duse='for i in G M K; do du -hsx * | grep "[0-9]$i\b" | sort -nr; done'

alias ducks='du -cks * | sort -rn | head -11'
alias buminimint='rsync -e ssh --progress /home/stevee/* stevee@minimint:/home/stevee/ --exclude='.' --exclude='Videos' -vrah'
alias buhpmint='rsync -e ssh --progress /home/stevee/* stevee@hpmint:/home/stevee/ --exclude='.' --exclude='Videos' -vrah'
alias budellmint='rsync -e ssh --progress /home/stevee/* stevee@dellmint:/home/stevee/ --exclude='.' --exclude='Videos' -vrah'

A good addition for du on dirs with very varied sizes:

alias duse='for i in G M K; do du -hsx * | grep "[0-9]$i\b" | sort -nr; done'

stevee@T3400 ~ $ duse
54G Pictures
43G Videos
22G VirtualBox VMs
21G Downloads
5.0G Music
56M Documents
14M Desktop
9.2M ID
80K Contacts
16K Templates
4.0K Public
4.0K index.html

remote rsync/ssh BUp without pword:

This should ask you for the password of your account on the remote server. The dot is so your setup files don't get sent also and possibly mess up the remote PC. The * prevents deletion of remote files that are already present in the same folder.

stevee@AMD ~ $ rsync -e ssh --progress /home/stevee/* stevee@dellmint:/home/stevee/ --exclude='.' --delete-excluded -vahn


2. ssh-keygen generates keys.

Now setup ssh so that it doesn’t ask for password when you perform ssh. Use ssh-keygen on local server to generate public and private keys.

$ ssh-keygen
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Note: When it asks you to enter the passphrase just press enter key, and do not give any password here.

3. ssh-copy-id copies public key to remote host

Use ssh-copy-id, to copy the public key to the remote host.

ssh-copy-id -i ~/.ssh/ dellmint
Note: The above will ask the password for your account on the remote host, and copy the public key automatically to the appropriate location. If ssh-copy-id doesn’t work for you, use the method we discussed earlier to setup ssh password less login.

4. Perform rsync over ssh without password

Now, you should be able to ssh to remote host without entering the password.

ssh dellmint
Perform the rsync again, it should not ask you to enter any password this time.

rsync -e ssh --progress /home/stevee/* stevee@dellmint:/home/stevee/ --exclude='Videos/' --delete-excluded -vahn
If you want to schedule an rsync backup job automatically, use crontab to set it up.

crontab -e

00 16 * * * rsync -e ssh /1500/* stevee@dellmint:/Quadra/ -a

Setup an alias for home dir backups - this one leaves files ALREADY on the remote PC intact when budellmint is run:

alias budellmint='rsync -e ssh --progress /home/stevee/* stevee@dellmint:/home/stevee/ --exclude=. -vrah'

view compressed logfiles without decomp:

sudo zcat /var/log/syslog.4.gz | grep restart

Jun 16 17:08:42 AMD cinnamon-killer-daemon: Bound Cinnamon restart to <Control><Alt>Escape.

Fix no locale UTF8 prob:

sudo locale-gen --purge --no-archive

Fastest DD speed for the quad core, 2GB/s?

stevee@MintMem ~ $ dd if=/dev/zero of=/dev/null bs=1M count=10
10+0 records in
10+0 records out
10485760 bytes (10 MB) copied, 0.00518111 s, 2.0 GB/s

Approx time taken to dd a 160GB SATA disk to a USB2 disk:

$ sudo dd if=/dev/sdc of=/dev/sdh
[sudo] password for stevee:
312581808+0 records in
312581808+0 records out
160041885696 bytes (160 GB) copied, 30962.4 s, 5.2 MB/s

30962/60*60  = 8.6 hrs

Use imagemagik to reduce multi pics size to 1/4 orig:

mogrify -resize 25% *.jpg

Using phpmyadmin to string replace - choose the DB, then SQL tab, then paste:

update wp_posts set post_content = replace(
post_content, 'Ashton',

Export a mysql DB:
mysqldump -u root -p wp > /home/stevee/Downloads/ElectMusic.sql

Mount a Win8 UEFI locked partition read only:

sudo mount -ro ntfs /dev/sda4 mymount/

Table 9-1. Run level numbers

0Halt the system.
1Single-user mode (for special administration).
2Local Multiuser with Networking but without network service (like NFS)
3Full Multiuser with Networking
4Not Used
5Full Multiuser with Networking and X Windows(GUI)

Broken install? Try: dpkg-reconfigure -a

-C, --audit
Searches for packages that have been installed only partially on
your system.

Random Number Gen - read man rand. Format = openssl rand [-out file] [-base64 | -hex] seed number e.g:

stevee@Mint5630 ~ $ openssl rand -out /dev/pts/1 -hex 1

should give a diff hex number each time

man hexdump

NUL \0
<alert character> \a
<backspace> \b
<form-feed> \f
<newline> \n
<carriage return> \r
<tab> \t
<vertical tab> \v

update grub in Mint:

vi /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" - I want to see the loading output, so remove these entries to ""
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.16.0-38-generic
Found initrd image: /boot/initrd.img-3.16.0-38-generic
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
No volume groups found
Found Windows Recovery Environment (loader) on /dev/sda5


Quick summary of BadPorts Post to strip the columns and dupe ports for nmap -p use, after copy/paste of the ports from:


vi BadPortsBig.txt
awk '{print $2}' BadPortsBig.txt
awk '{print $2}' BadPortsBig.txt > BadPortsOnlyBig.txt
uniq BadPortsOnlyBig.txt > BadPortsOnlyBigNoDupes.txt
cat BadPortsBig.txt | wc -l

cat BadPortsOnlyBigNoDupes.txt | wc -l


tr '\n' ',' < BadPortsOnlyBigNoDupes.txt

65422,65432,65530,65535,AMDA8 Documents #

tr '\n' ',' < BadPortsOnlyBigNoDupes.txt > BadPortsCommas.txt

Or just reduced to:

cut -d " " -f2 BadPortsBig.txt | uniq | sed ':a;N;$!ba;s/\n/,/g'> BadPortsCommas.txt

nmap -p $(cat BadPortsCommas.txt)

Not shown: 788 closed ports
22/tcp open ssh
139/tcp open netbios-ssn
445/tcp open microsoft-ds


apt-cache pkgnames | sort > pkgs.txt

apt-cache pkgnames | wc -l


Remove duplicate lines with uniq. This leaves the original file unchanged, so you need to pipe the fix to another file e.g.

cat /aabbcc.txt

uniq /aabbcc.txt

uniq /aabbcc.txt > /abcd.txt

Find words in the Linux dictionary file:

grep '\<c...h\>' /usr/share/dict/words

apt-get install sysadmin-guide


Post on Older Fundamental Admin commands? incl:


set your timezone:

sudo dpkg-reconfigure tzdata

man cal

cal -j 2015

August 2015
Su Mo Tu We Th Fr Sa
214 215 216 217 218 219 220
221 222 223 224 225 226 227
228 229 230 231 232 233 234
235 236 237 238 239 240 241
242 243

man date

-s, --set=STRING
set time described by STRING

date -s="Sun, 29 Feb 2016 16:21:42 -0800"
date: invalid date ‘=Sun, 29 Feb 2016 16:21:42 -0800’

Unix Start time

date --date='@0' 

set month, day, time (hr:mm), year:

date 1103231401
Fri Nov 3 23:14:00 GMT 2001

date 110323141964
date: cannot set date: Invalid argument (but works!)
Tue Nov 3 23:14:00 GMT 1964

Another method would be to use either hwclock -w or hwclock --systohc to sync the hardware clock to the software clock. If you want to sync your software clock to your hardware clock then you would use hwclock -s or hwclock --hwtosys.

date is also used to set the kernel's software clock:
# date 07142157

Tue Jul 14 21:57:00 BST 2015

date -R output date and time in RFC 2822 format
Sun, 30 Aug 2015 22:23:35 +0100

2 Sep 22:37:16 ntpdate[4559]: adjust time server offset -0.007021 sec

vi /etc/default/ntpdate


PING ( 56(84) bytes of data.
64 bytes from ( icmp_seq=1 ttl=50 time=28.5 ms

This will contact an NTP server and determine the time difference but not change your system's time.

ntpdate -d

3 Sep 11:58:00 ntpdate[11913]: adjust time server offset 0.001958 sec

cat alphas.txt

od -bc alphas.txt

0000000 141 142 143 144 145 146 147 150 151 152 153 154 155 156 157 160
                   a     b      c     d     e     f      g     h     i      j      k     l     m    n     o     p
0000020 161 162 163 164 165 166 167 170 171 172 012 101 102 103 104 105
                   q      r     s      t      u    v     w     x     y    z    \n    A     B    C    D    E
0000040 106 107 110 111 112 113 114 115 116 117 120 121 122 123 124 125
                   F     G    H     I     J      K    L    M   N    O     P    Q    R     S     T    U
0000060 126 127 130 131 132 077 012
                   V   W    X    Y    Z     ?    \n

Compare two files byte by byte.

-l, --verbose
output byte numbers and differing byte values

cat alphas2.txt
Mint5630 stevee # cat alphas.txt
Mint5630 stevee # cmp alphas.txt alphas2.txt
alphas.txt alphas2.txt differ: byte 54, line 2

cmp -l alphas.txt alphas2.txt
54 77 12  (line no, 2 differing file bytes)

od -bc alphas.txt
0000060 126 127 130 131 132 077 012
                                                      ?    \n

diff alphas2.txt alphas.txt

Running Processes

ps ua
root 785 0.0 0.0 15824 2048 tty4 Ss+ 12:41 0:00 /sbin/getty
root 789 0.0 0.0 15824 2004 tty5 Ss+ 12:41 0:00 /sbin/getty
root 804 0.0 0.0 15824 1996 tty2 Ss+ 12:41 0:00 /sbin/getty
root 805 0.0 0.0 15824 1992 tty3 Ss+ 12:41 0:00 /sbin/getty
root 808 0.0 0.0 15824 1992 tty6 Ss+ 12:41 0:00 /sbin/getty
root 1214 1.3 0.9 378880 64704 tty8 Ssl+ 12:41 8:14 /usr/bin/X :
root 1821 0.0 0.0 15824 2072 tty1 Ss+ 12:41 0:00 /sbin/getty
stevee 3160 0.0 0.0 22636 5144 pts/0 Ss 12:48 0:00 bash
root 3177 0.0 0.0 89148 4324 pts/0 S 12:48 0:00 su -
root 3185 0.0 0.0 23108 5824 pts/0 S 12:48 0:01 -su
stevee 4126 0.0 0.0 22728 5328 pts/3 Ss 14:00 0:00 -bash
root 4144 0.0 0.0 89152 4388 pts/3 S 14:00 0:00 su root
root 4151 0.0 0.0 22736 5464 pts/3 S+ 14:00 0:00 bash
root 4341 69.3 1.1 101908 76808 pts/0 R+ 14:34 357:16 rsync /Store
root 4342 0.0 0.4 73576 32240 pts/0 S+ 14:34 0:03 rsync /Store
root 4343 12.8 2.9 263768 195304 pts/0 S+ 14:34 66:12 rsync /Store
stevee 5859 0.0 0.0 22728 5332 pts/4 Ss 21:34 0:00 -bash
stevee 6210 0.0 0.0 18460 2552 pts/4 R+ 23:09 0:00 ps ua

ps auf (tree) or pstree
stevee 7373 0.0 0.1 7048 4676 pts/3 Ss 13:05 0:00 bash
root 7392 0.0 0.1 8404 4076 pts/3 S 13:05 0:00 \_ su root
root 7400 0.0 0.1 7140 4876 pts/3 S+ 13:05 0:00 \_ bash
stevee 3245 0.0 0.1 6992 4676 pts/1 Ss 11:29 0:00 bash
root 3304 0.0 0.1 8404 4060 pts/1 S 11:29 0:00 \_ su root
root 3317 0.0 0.1 7192 4992 pts/1 S 11:29 0:00 \_ bash
root 7874 0.0 0.0 5232 2368 pts/1 R+ 13:45 0:00 \_ ps auf
root 1491 2.1 1.3 186784 43224 tty8 Ssl+ 11:28 2:59 /usr/bin/X :0 -audit 0 -auth /va

man mkfs - build a Linux filesystem

password checks:

cracklib-check - Check passwords using libcrack2, FascistCheck


The file descriptors for stdin, stdout, and stderr are 0, 1, and 2, respectively.

SETUID PERM - non exe and exe

locate passwd | grep /usr/bin


Preventing compromise of user accounts relies on all accounts having passwords that are not easily guessable.
Attackers on the Internet regularly use automated tools, often called "ssh scanners," which attempt to log in to systems using a wide selection of commonly known usernames and a set of passwords, mostly dictionary words. The scanner additionally tries using the username as the password (e.g. username "john" and password "john"). SDSC systems networks undergo these attacks daily; choosing a weak password for an account will result in a compromise of that account.
Additionally, when an attacker gains access to a system, he/she will often steal encrypted passwords from the /etc/shadow file and attempt to determine passwords to accounts by running a program such as [Crack, which takes a large dictionary of words, encrypts them, and matches the result against what is stored in the shadow file. Crack also tries common variations of words, such as substituting 1 (one) for l (ell), $ for S, etc.
Many security tutorials suggest rules for password creation, such as including punctuation, etc. But fending of ssh scans and crack attempts can be fended off simply by preventing users from choosing passwords from the dictionary that attackers use.

The legacy UNIX System encryption method is based on the NBS DES algorithm. More
recent methods are now recommended (see ENCRYPT_METHOD).

Use the crypt(3) function. On glibc, the method used depends on the salt, if it starts with:

$1$: it uses MD5.
$5$: it uses SHA-256.
$6$: it uses SHA-512. (See stevee below)
$2a$: it uses blowfish, not supported everywhere.
Otherwise it uses DES.

In /etc/shadow:


Or from the length of Field2 itself:

MD5     | 22 characters
SHA-256 | 43 characters
SHA-512 | 86 characters

The characters in "salt" and "encrypted" are drawn from the set [a-zA-Z0-9./]. In the MD5 and SHA implementations the entire key is significant (instead of only the first 8 bytes in DES).

des_crypt, ecb_crypt, cbc_crypt, des_setparity, DES_FAILED - fast
DES encryption

passwd uses PAM to authenticate users and to change their passwords.

Most Unicies (and Linux is no exception) primarily use a one-way encryption algorithm, called DES (Data Encryption Standard) to encrypt your passwords. This encrypted password is then stored in (typically) /etc/passwd (or less commonly) /etc/shadow. When you attempt to login, the password you type in is encrypted again and compared with the entry in the file that stores your passwords. If they match, it must be the same password, and you are allowed access. Although DES is a two-way encryption algorithm (you can code and then decode a message, given the right keys), the variant that most Unixes use is one-way. This means that it should not be possible to reverse the encryption to get the password from the contents of /etc/passwd (or /etc/shadow).

Brute force attacks, such as "Crack" or "John the Ripper" (see section Section 6.9) can often guess passwords unless your password is sufficiently random. PAM modules (see below) allow you to use a different encryption routine with your passwords (MD5 or the like). You can use Crack to your advantage, as well. Consider periodically running Crack against your own password database, to find insecure passwords. Then contact the offending user, and instruct him to change his password.

ls -als /usr/bin/passwd
48 -rwsr-xr-x 1 root root 45420 Jul 15 20:31 /usr/bin/passwd

passwd is owned by root, yet users can use it to change their pword - why..? Setbits!

“Regardless of who runs this program, run it as the user who owns it, not the user that executes it.”

Mint5630 stevee # touch /script.txt
Mint5630 stevee # chmod 4644 /script.txt
Mint5630 stevee # ls -als /script.txt
0 -rwSr--r-- 1 root root 0 Aug 31 09:56 /script.txt

Mint5630 stevee # chmod 2644 /script.txt
Mint5630 stevee # ls -als /script.txt
0 -rw-r-Sr-- 1 root root 0 Aug 31 09:56 /script.txt

Mint5630 stevee # ls -als /script.txt
0 -rw-r-sr-- 1 root root 0 Aug 31 09:56 /script.txt

Sticky Bit - non exe and exe

Mint5630 stevee # ls -als /script.txt
0 -rw-r--r-T 1 root root 0 Aug 31 09:56 /script.txt

Mint5630 stevee # ls -als /script.txt
0 -rw-r--r-t 1 root root 0 Aug 31 09:56 /script.txt

Password Files Fields Meanings

stevee@Mint5630 ~ $ sudo cat /etc/shadow | grep stevee
[sudo] password for stevee:

note; same username, same pw on 2 diff PCs renders different hashes:



F1 Name; F2 pw enc (98 chars); F3 days since Jan1, 1970 (16661 days = 45 yrs); F4 min days pw retained (0 = can never change); F5 max days until pword must change (99999 days = 273 yrs); F6 days before expiry warning (7); F7 (null); F8 null); F9 unused

In Ubuntu/Mint, the enc method (used with a SALT) is found in:

vi /etc/pam.d/common-password

# here are the per-package modules (the "Primary" block)
password [success=1 default=ignore] obscure sha512

The passwd file shows x - enc not held here - the home dir and the shell the user will boot into:


Counting Line Bytes (-c) or Chars (-m), removing columns and chars

Take the /etc/shadow field 2 as an example, put in /file.txt where vi shows the visible characters as numbering 98:


1,98 All

but, with a hidden newline char (\n = 012) shown by:

wc -m < /file.txt

shown by od:


or better, just -c; ASCII character or backslash escape:


This shows the passwd hash letters in a grid of 16 x 6 + 3 = 99.

Using awk to show all but column $1:

od -c /file.txt | awk '{print $2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16}'
$ 6 $ w D W X f U S 0 $ H m W
E x 1 s v v d P a B 5 O 9 E O
j i g 9 8 S r f x t a 0 9 R 5
Z L r c P I I r b Q 5 j B t b
k D S M R 6 y Z T E r v 5 2 x
. n O L k C F z S t D X c l O
b . \n

or more elegantly;

od -c /file.txt | awk '{$1=""; print $0}'
$ 6 $ w D W X f U S 0 $ H m W z
E x 1 s v v d P a B 5 O 9 E O z
j i g 9 8 S r f x t a 0 9 R 5 X
Z L r c P I I r b Q 5 j B t b m
k D S M R 6 y Z T E r v 5 2 x P
. n O L k C F z S t D X c l O j
b . \n

Remove the final \n:

od -c /file.txt | awk '{$1=""; print $0}' | sed 's/\\n//'
$ 6 $ w D W X f U S 0 $ H m W z
E x 1 s v v d P a B 5 O 9 E O z
j i g 9 8 S r f x t a 0 9 R 5 X
Z L r c P I I r b Q 5 j B t b m
k D S M R 6 y Z T E r v 5 2 x P
. n O L k C F z S t D X c l O j
b .

or even more elegantly using cut, where each char is counted from left, so from char 11 onwards:


You can still pipe that into sed to remove the final \n also.

od -c /file2.txt | cut -c 11- | sed 's/\\n//'
$ 6 $ w D W X f U S 0 $ H m W z
E x 1 s v v d P a B 5 O 9 E O z
j i g 9 8 S r f x t a 0 9 R 5 X
Z L r c P I I r b Q 5 j B t b m
k D S M R 6 y Z T E r v 5 2 x P
. n O L k C F z S t D X c l O j
b .

Note that vi counts only visible characters - 98 total, but wc -m will count the \n:


cat /file2.txt | wc -m

BEWARE! You can get some bizarre and unexpected results in streamed combos:


212 chars counted but only 98 shown, which is the original correct amount on one line plus \n!

cat /file2.txt | wc -m

To finish, use paste to glue back the 2 sections again with a delimiter of choice, once the 2 files are prepared e.g.:



FSCK mounted FS

fsck -n
fsck from util-linux 2.20.1
e2fsck 1.42.9 (4-Feb-2014)
Warning! /dev/sda1 is mounted.
Warning: skipping journal recovery because doing a read-only filesystem check.
/dev/sda1: clean, 196568/2313808 files, 5561526/9243392 blocks

badblocks -vv /dev/sda1
Checking blocks 0 to 36973567
Checking for bad blocks (read-only test): 0.00% done, 0:00 elapsed. (0/0/0 errdone 
Pass completed, 0 bad blocks found. (0/0/0 errors)

BACKUPS - old, redundant, but interesting

Mint5630 Downloads # ls | cpio -ov > /dev/sdb
166115 blocks

ls | cpio -ivm < /dev/sdb
cpio: 20140122143951478.rar not created: newer or same age version exists
cpio: 20150206145713250.rar not created: newer or same age version exists
cpio: not created: newer or same age version exists
cpio: not created: newer or same age version exists
cpio: openprinting-ppds-postscript-lexmark_20140829-1lsb3.2_all.deb not created: newer or same age version exists
166115 blocks

System HW info:

sudo lshw -html > hardware_info.html

firefox hardware_info.html


find / -size +3G 2> /dev/null


find / -name *.iso


$ sudo find / -name *.img -size +3G 2> /dev/null

Modification time (days)

find . -mtime +365


find /Share/ \( -user stevee -a -size +2G \)

There must be a space between the last curly and the backslash!

find /home/ \( -mtime +65 -a -atime +65 \) -exec cp -vt /Share/ {} \;
‘/home/stevee/Downloads/Vigor2860FWare/STD/v2860_3783.rst’ -> ‘/Share/v2860_3783.rst’
‘/home/stevee/Downloads/Vigor2860FWare/STD/v2860_3783.all’ -> ‘/Share/v2860_3783.all’

Backup a day's files:

find /home/stevee/Documents/ -mtime +1 -exec cp -vt /Share/ {} \;
cp: omitting directory ‘/home/stevee/Documents/’
‘/home/stevee/Documents/Webcam.odt’ -> ‘/Share/Webcam.odt’
‘/home/stevee/Documents/Fix Double Minus Sign Problem in WordPress in Theme Functions php.odt’ -> ‘/Share/Fix Double Minus Sign Problem in WordPress in Theme Functions php.odt’
‘/home/stevee/Documents/Vista 32 bit PC: Alex’ -> ‘/Share/Vista 32 bit PC: Alex’

TAR - tape archive - note the tar file name/creation comes before the files to go in it!

tar -cf archive.tar foo bar # Create archive.tar from files foo and bar.
tar -tvf archive.tar # List all files in archive.tar verbosely.
tar -xvf archive.tar # Extract all files from archive.tar.

-d; creates dirs

-c; write header info in ASCII

-r; interactive renaming

-t; list archive files

-u; overwrite newer file with older

-v; verbose

-m; retain mod time

-f exp; copy all except those in exp

If you use full relative pathnames then files are restored back where they came from, but tar may not read "*" for replacement though it used them for backup. Tar copies subdirs by default, and creates them on restore if req.

Create a tar in /Share of all files in pwd

MintServer Documents # tar cvf /Share/Docs.tar *
Fix Double Minus Sign Problem in WordPress in Theme Functions php.odt
Vista 32 bit PC: Alex

List contents

MintServer Documents # tar tvf /Share/Docs.tar
-rw-r--r-- stevee/stevee 405667840 2015-09-01 16:19 Fix Double Minus Sign Problem in WordPress in Theme Functions php.odt
-rw-r--r-- stevee/stevee 1198 2015-08-28 10:21 Vista 32 bit PC: Alex
-rw-r--r-- stevee/stevee 24579 2015-08-07 14:45 Webcam.odt


tar -xvf /Share/Docs.tar
Fix Double Minus Sign Problem in WordPress in Theme Functions php.odt
Vista 32 bit PC: Alex

TAR options - check against current man page

-r; appends to archive end

-x; extract recursively

-t; list files, long format

- u; as -r but for newer files than present

-c; new archive an a device

-w; confirm

-m; change mod time to extract time

-o; change owner to extractor



apt-get install ytalk

----------------------------= YTalk version 3.3.0 =-----------------------------

----------------------------= stevee@ =-----------------------------

AT command and redirecting the result (as AT sends a mail by default - no MTA installed, no msg)

"The user will be mailed standard error and standard output from his commands, if sendmail"

at now + number period. The period can be minutes, hours, days, or weeks. The number simply indicates the number of said units that must elapse before execution of the command.

at 09:00 27.07.14 <<END
> echo "Don't forget to wish a Happy Birthday to Raphaël!" \
>   | mail

at 1445 << END
> date > /dev/pts/5
warning: commands will be executed using /bin/sh
job 13 at Wed Sep 2 14:45:00 2015

The output shows secs after 14:45 in term pts/5:

Wed Sep 2 14:45:00 BST 2015

Show the At queue:


9 Thu Sep 3 14:34:00 2015 a root

delete job 9:

atrm 9

or queue:

at -l
17 Wed Sep 2 15:18:00 2015 a root

at 1458 << END
> rsync Downloads/Vigor2860FWare /media/stevee/A8B8-81C3/ --progress -vrazhn > /dev/pts/5

warning: commands will be executed using /bin/sh
job 14 at Wed Sep 2 14:58:00 2015

In pts/5:

MintServer stevee # sending incremental file list

sent 159 bytes received 30 bytes 378.00 bytes/sec
total size is 26.09M speedup is 138,032.87 (DRY RUN)

Generate PC Hardware Report

lshw -html > /hwreport.html

description:Desktop Computer
product:E4264 ()
width:64 bits
capabilities:smbios-2.4 dmi-2.4 vsyscall32

STAT command - formatted file info output - from Will Shot's site

Using the -f option, we can examine file systems as well:

bshotts@twin7:~$ stat -f /
File: "/"
ID: 9e38fe0b56e0096d Namelen: 255     Type: ext2/ext3
Block size: 4096       Fundamental block size: 4096
Blocks: Total: 18429754   Free: 10441154   Available: 9504962
Inodes: Total: 4685824    Free: 4401092

Clearly stat delivers the goods when it comes to file information, but what about that output format?  I can't think of anything worse to deal with from a script writer's point-of-view (actually I can, but let's not go there!).

Here's where the beauty of stat starts to shine through.  The output is completely customizable.  stat supportsprintf-like format specifiers.  Here is an example extracting just the name, size, and octal file permissions:

bshotts@twin7:~$ stat -c "%n  %s  %a" .bashrc
.bashrc  3800  644

The -c option provides basic formatting capabilities, while the --printf option can do even more by interpreting backslash escape sequences:

bshotts@twin7:~$ stat --printf="%n\t%s\t%a\n" .bashrc
.bashrc    3800    644

Using this format, we can produce tab-delimited output, perfect for processing by the cut command.  Each of the fields in the stat output is available for formatting.  See the stat man page for the complete list.

DUMP/RESTORE - see cpio also

a level 0 dump is a full filesys backup - e.g. first used before later incremental BUs

/dev/sda1: UUID="436a55a9-f610-45f6-866d-a72bfe10ff74" TYPE="ext4"
/dev/sda5: UUID="185ec76d-f2a0-49fd-a3b5-bd5ee859a18b" TYPE="swap"
/dev/sdb1: UUID="5C90-48F8" TYPE="vfat"
Mint5630 Pictures # dump -0 -f /dev/sdb1 /home/stevee/Pictures
DUMP: Date of this level 0 dump: Wed Sep 2 23:33:21 2015
DUMP: Dumping /dev/sda1 (/ (dir home/stevee/Pictures)) to /dev/sdb1
DUMP: Label: none
DUMP: Writing 10 Kilobyte records
DUMP: mapping (Pass I) [regular files]
DUMP: mapping (Pass II) [directories]
DUMP: estimated 897 blocks.
DUMP: Volume 1 started with block 1 at: Wed Sep 2 23:33:21 2015
DUMP: dumping (Pass III) [directories]
DUMP: dumping (Pass IV) [regular files]
DUMP: Closing /dev/sdb1
DUMP: Volume 1 completed at: Wed Sep 2 23:33:23 2015
DUMP: Volume 1 880 blocks (0.86MB)
DUMP: Volume 1 took 0:00:02
DUMP: Volume 1 transfer rate: 440 kB/s
DUMP: 880 blocks (0.86MB) on 1 volume(s)
DUMP: finished in 1 seconds, throughput 880 kBytes/sec
DUMP: Date of this level 0 dump: Wed Sep 2 23:33:21 2015
DUMP: Date this dump completed: Wed Sep 2 23:33:23 2015
DUMP: Average transfer rate: 440 kB/s

RESTORE is a prob with pen drive...

fdisk -l /dev/sda

Disk /dev/sda: 40.0 GB, 40007761920 bytes
255 heads, 63 sectors/track, 4864 cylinders, total 78140160 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000d2419

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 73949183 36973568 83 Linux
/dev/sda2 73951230 78139391 2094081 5 Extended
/dev/sda5 73951232 78139391 2094080 82 Linux swap / Solaris

fdisk /dev/sda

Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the DOS compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

Command (m for help): l

0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris
1 FAT12 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT-
2 XENIX root 39 Plan 9 83 Linux c4 DRDOS/sec (FAT-
3 XENIX usr 3c PartitionMagic 84 OS/2 hidden C: c6 DRDOS/sec (FAT-
4 FAT16 <32M 40 Venix 80286 85 Linux extended c7 Syrinx
5 Extended 41 PPC PReP Boot 86 NTFS volume set da Non-FS data
6 FAT16 42 SFS 87 NTFS volume set db CP/M / CTOS / .
7 HPFS/NTFS/exFAT 4d QNX4.x 88 Linux plaintext de Dell Utility
8 AIX 4e QNX4.x 2nd part 8e Linux LVM df BootIt
9 AIX bootable 4f QNX4.x 3rd part 93 Amoeba e1 DOS access
a OS/2 Boot Manag 50 OnTrack DM 94 Amoeba BBT e3 DOS R/O
b W95 FAT32 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor
c W95 FAT32 (LBA) 52 CP/M a0 IBM Thinkpad hi eb BeOS fs
e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD ee GPT
f W95 Ext'd (LBA) 54 OnTrackDM6 a6 OpenBSD ef EFI (FAT-12/16/
10 OPUS 55 EZ-Drive a7 NeXTSTEP f0 Linux/PA-RISC b
11 Hidden FAT12 56 Golden Bow a8 Darwin UFS f1 SpeedStor
12 Compaq diagnost 5c Priam Edisk a9 NetBSD f4 SpeedStor
14 Hidden FAT16 <3 61 SpeedStor ab Darwin boot f2 DOS secondary
16 Hidden FAT16 63 GNU HURD or Sys af HFS / HFS+ fb VMware VMFS
17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fc VMware VMKCORE
18 AST SmartSleep 65 Novell Netware b8 BSDI swap fd Linux RAID auto
1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fe LANstep
1c Hidden W95 FAT3 75 PC/IX be Solaris boot ff BBT
1e Hidden W95 FAT1 80 Old Minix

"Modern Linux filesystem keep fragmentation at a minimum by keeping all blocks in a file close together, even if they can't be stored in consecutive sectors. Some filesystems, like ext3, effectively allocate the free block that is nearest to other blocks in a file. Therefore it is not necessary to worry about fragmentation in a Linux system."

HOWEVER...good to know how...

apropos defrag
e4defrag (8) - online defragmenter for ext4 filesystem

man e4defrag

e4defrag - online defragmenter for ext4 filesystem

e4defrag [ -c ] [ -v ] target ...

e4defrag reduces fragmentation of extent based file. The file tar‐
geted by e4defrag is created on ext4 filesystem made with "-O
extent" option (see mke2fs(8)). The targeted file gets more con‐
tiguous blocks and improves the file access speed.

target is a regular file, a directory, or a device that is mounted
as ext4 filesystem. If target is a directory, e4defrag reduces
fragmentation of all files in it. If target is a device, e4defrag
gets the mount point of it and reduces fragmentation of all files in
this mount point.

-c Get a current fragmentation count and an ideal fragmentation
count, and calculate fragmentation score based on them. By
seeing this score, we can determine whether we should execute
e4defrag to target. When used with -v option, the current
fragmentation count and the ideal fragmentation count are
printed for each file.

Also this option outputs the average data size in one extent.
If you see it, you'll find the file has ideal extents or not.
Note that the maximum extent size is 131072KB in ext4
filesystem (if block size is 4KB).

If this option is specified, target is never defragmented.

-v Print error messages and the fragmentation count before and
after defrag for each file.

e4defrag /home/stevee/

[4344/4344]/home/stevee/.macromedia/Flash_Player/#SharedObjects/ZN9NYCUV/ 100% [ OK ]

Success: [ 3405/4344 ]
Failure: [ 939/4344 ]

e4defrag -vc /dev/sda1

[197662/197662] "/MINTSERVER"
File is not regular file

<Fragmented files> now/best size/ext
1. /var/log/ConsoleKit/history.1 11/1 4 KB
2. /var/log/pm-powersave.log.1 6/1 4 KB
3. /var/log/auth.log.1 6/1 4 KB
4. /var/log/ConsoleKit/history 5/1 4 KB
5. /var/log/wtmp.1 17/1 4 KB

Total/best extents 139974/139341
Average size per extent 149 KB
Fragmentation score 0
[0-30 no problem: 31-55 a little bit fragmented: 56- needs defrag]
This device (/dev/sda1) does not need defragmentation.


du -sh /
du: cannot access ‘/run/user/1000/gvfs’: Permission denied
du: cannot access ‘/proc/7954/task/7954/fd/4’: No such file or directory
du: cannot access ‘/proc/7954/task/7954/fdinfo/4’: No such file or directory
du: cannot access ‘/proc/7954/fd/4’: No such file or directory
du: cannot access ‘/proc/7954/fdinfo/4’: No such file or directory
93G /

du -sh /home/stevee/
13G /home/stevee/

df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 146G 93G 46G 68% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
udev 1.5G 8.0K 1.5G 1% /dev
tmpfs 304M 2.3M 302M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 1.5G 59M 1.5G 4% /run/shm
none 100M 32K 100M 1% /run/user

df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 146G 93G 46G 68% /


Mint5630 stevee # w
17:10:57 up 8:11, 3 users, load average: 2.14, 2.22, 2.44
stevee tty8 :0 09:01 8:11m 20:46 0.79s cinnamon-session --session cinnamon2d
stevee pts/1 :0 09:12 1:02m 2:50 8:45 gnome-terminal

Keys info:

dpkg-reconfigure keyboard-configuration
vi /etc/default/keyboard
apt-get install console-data
dpkg-reconfigure console-data