Sometimes it is nice to send a log or some other file as a email to someone (or a part of a file)
cat myfile.txt | mail -s 'SUBJECT' example@mail.com;
Change myfile.txt, SUBJECT and example@mail.com to something useful.
Sometimes it is nice to send a log or some other file as a email to someone (or a part of a file)
cat myfile.txt | mail -s 'SUBJECT' example@mail.com;
Change myfile.txt, SUBJECT and example@mail.com to something useful.
Finding the serial number of a hard drive on a Linux console (as root) is simple with the right tool.
The right tool in this case is hdparm (using the -i option).
-i will query the device directly for the details.
Example:
themachine:/proc# hdparm -i /dev/sda /dev/sda: Model=ST31500341AS , FwRev=CC1H , SerialNo= 9VS21ZXM Config={ HardSect NotMFM HdSw>15uSec Fixed DTR>10Mbs RotSpdTol>.5% } RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=4 BuffType=unknown, BuffSize=0kB, MaxMultSect=16, MultSect=?16? CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=18446744072344861488 IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120} PIO modes: pio0 pio1 pio2 pio3 pio4 DMA modes: mdma0 mdma1 mdma2 UDMA modes: udma0 udma1 udma2 udma3 udma4 udma5 *udma6 AdvancedPM=no WriteCache=enabled Drive conforms to: unknown: ATA/ATAPI-4,5,6,7 * signifies the current active mode
Using the option -I instead gives even more information:
themachine:/proc# hdparm -I /dev/sda /dev/sda: ATA device, with non-removable media Model Number: ST31500341AS Serial Number: 9VS21ZXM Firmware Revision: CC1H Transport: Serial Standards: Used: unknown (minor revision code 0x0029) Supported: 8 7 6 5 Likely used: 8 Configuration: Logical max current cylinders 16383 16383 heads 16 16 sectors/track 63 63 -- CHS current addressable sectors: 16514064 LBA user addressable sectors: 268435455 LBA48 user addressable sectors: 2930277168 device size with M = 1024*1024: 1430799 MBytes device size with M = 1000*1000: 1500301 MBytes (1500 GB) Capabilities: LBA, IORDY(can be disabled) Queue depth: 32 Standby timer values: spec'd by Standard, no device specific minimum R/W multiple sector transfer: Max = 16 Current = ? Recommended acoustic management value: 254, current value: 0 DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 udma5 *udma6 Cycle time: min=120ns recommended=120ns PIO: pio0 pio1 pio2 pio3 pio4 Cycle time: no flow control=120ns IORDY flow control=120ns Commands/features: Enabled Supported: * SMART feature set Security Mode feature set * Power Management feature set * Write cache * Look-ahead * Host Protected Area feature set * WRITE_BUFFER command * READ_BUFFER command * DOWNLOAD_MICROCODE SET_MAX security extension * Automatic Acoustic Management feature set * 48-bit Address feature set * Device Configuration Overlay feature set * Mandatory FLUSH_CACHE * FLUSH_CACHE_EXT * SMART error logging * SMART self-test * General Purpose Logging feature set * WRITE_{DMA|MULTIPLE}_FUA_EXT * 64-bit World wide name Write-Read-Verify feature set * WRITE_UNCORRECTABLE_EXT command * {READ,WRITE}_DMA_EXT_GPL commands * Segmented DOWNLOAD_MICROCODE * SATA-I signaling speed (1.5Gb/s) * SATA-II signaling speed (3.0Gb/s) * Native Command Queueing (NCQ) * Phy event counters Device-initiated interface power management * Software settings preservation * SMART Command Transport (SCT) feature set * SCT Long Sector Access (AC1) * SCT LBA Segment Access (AC2) * SCT Error Recovery Control (AC3) * SCT Features Control (AC4) * SCT Data Tables (AC5) unknown 206[12] (vendor specific) Security: Master password revision code = 65534 supported not enabled not locked not frozen not expired: security count supported: enhanced erase 240min for SECURITY ERASE UNIT. 240min for ENHANCED SECURITY ERASE UNIT. Logical Unit WWN Device Identifier: 5000c50014ec1f60 NAA : 5 IEEE OUI : c50 Unique ID : 014ec1f60 Checksum: correct
To mark a message as unread in pine this can be done using flags.
First flags have to be turned on in setup
[M]ain [S]etup [C]onfig
Then find “enable-flag-cmd” and turn it on.
After this marking a message as unread is done by “* N” in the list view or when looking at the message.
All the flags are:
[^T] Can be used to see all the flags and set/unset them one by one (or all).
apt-get is verifying the packages before installing them.
If the keys are not up to date, then apt-get upgrade will issue a warning.
WARNING: The following packages cannot be authenticated! ure uno-libs3 Install these packages without verification [y/N]?
The way to solve this is rather simple, just run apt-get update and it should download the keys automatically.
apt-key handles keys, using apt-key list will show you the keys that are on the computer.
Sometimes it is nice to limit the download speed of apt-get.
The way I do this is to create a file “/etc/apt/apt.conf.d/76download” and enter the following to it
Acquire{Queue-mode "access";http{Dl-Limit "50";};};
This will limit apt-get to at most 50 kb/s for apt-get.
Some other how to’s suggest the use of dl-limit but be adviced, dl-limit is per each connection apt-get does (normally it does 2 at a time); the one used above caps apt-get in total.
Using SSH you can run commands at remote servers.
By default the remote server will ask for credentials but for instance when writing a script it is not a good idea to store the login credentials in a script.
The solution to this is to create a key pair at the origin machine (where the script is) and then send this key to the remoteserver (where the script needs to login).
jonas@jonas-desktop:~$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/jonas/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/jonas/.ssh/id_rsa. Your public key has been saved in /home/jonas/.ssh/id_rsa.pub. The key fingerprint is: 11:f9:5a:8f:7d:74:e4:68:3b:4b:22:1c:78:e6:be:2d jonas@jonas-desktop The key's randomart image is: +--[ RSA 2048]----+ | .. | | .. .| | .o + | | ..* + o| | SB = o o | | . = + = | | . . + o | | E. . | | .o. | +-----------------+
Passphrase is needed to “unlock” this key before being able to use it. Leaving passphrase blank means that the key can be used without any inputs.
jonas@jonas-desktop:~$ ssh-copy-id -i .ssh/id_rsa.pub user@remoteserver Warning: Permanently added 'remoteserver,11.222.333.222' (RSA) to the list of known hosts. user@remoteserver's password: Now try logging into the machine, with "ssh 'user@remoteserver'", and check in: .ssh/authorized_keys to make sure we haven't added extra keys that you weren't expecting.
-i is the identity file we created with ssh-keygen
This is it. Now you are able to login to remoteserver as user without a password.
By default untaring will put the contents into the current directory.
Sometimes it is not desirable to change directory to the target (such as in a scrip).
tar -xvvf /source/tarfile.tar -C /target
This will extract(x), very verbosly(vv) the file(f) /source/tarfile.tar to the directory(-C) /target (it will change the output folder to /target (so make sure it exists).
# default behavior for the release upgrader # [DEFAULT] # default prompting behavior, valid options: # never - never prompt for a new distribution version # normal - prompt if a new version of the distribution is available # lts - prompt only if a LTS version of the distribution is available Prompt=normal
netstat can be used to figure out what program is using a port.
$ netstat -nlp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1096/sshd tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1733/apache2 tcp6 0 0 :::22 :::* LISTEN 1096/sshd Active UNIX domain sockets (only servers) Proto RefCnt Flags Type State I-Node PID/Program name Path unix 2 [ ACC ] STREAM LISTENING 6338 1071/gdm-simple-sla @/tmp/gdm-greeter-LvjLQPzT unix 2 [ ACC ] STREAM LISTENING 5165 1072/X /tmp/.X11-unix/X0
If you have a lot open then grep can be used to only find what you are looking for
netstat -nlp|grep :22 tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1096/sshd tcp6 0 0 :::22 :::* LISTEN 1096/sshd
For windows, simply start with
netstat -n
The arp cache should (normally) be cleared within 20 minutes (or less, this depends on what platform is used).
If you don’t know what ARP is and what is is good for, then perhaps you should take a moment and read the man page:
DESCRIPTION Arp manipulates or displays the kernels IPv4 network neighbor cache. It can add entries to the table, delete one or display the current content. ARP stands for Address Resolution Protocol, which is used to find the media access control address of a network neighbor for a given IPv4 Address.
On a windows platform to show the arp cache
C:\> arp -a Interface: 192.168.1.49 --- 0xb Internet Address Physical Address Type 192.168.1.29 00-1d-92-08-49-25 dynamic 192.168.1.34 00-24-81-85-ab-b6 dynamic
To clear the cache
C:\>netsh interface ip delete arpcache
Ok.To show the arp cache on a nix machine:
$ arp -vn; cat /proc/net/arp Address HWtype HWaddress Flags Mask Iface 192.168.1.254 ether 00:08:ae:09:20:a0 C eth0 IP address HW type Flags HW address Mask Device 192.168.1.254 0x1 0x2 00:08:ae:09:20:a0 * eth0
To clear the apr cache on a nix machine.
$ ip neigh flush all