Oct 9th, 2012

How to pronounce Linux

Internet newsgroup participants have long debated the proper pronunciation of Linux. Because the name Linux was conferred by Linux kernel author Linus Torvalds, his pronunciation of the word should reign as standard as I see it. However, Linus is Finnish and his pronunciation of Linux is difficult for English speakers to approximate. Consequently, many variations in pronunciation have arisen. The most popular pronunciation sounds as though the word were spelled Linnucks, with the stress on the first syllable.

You can hear how Linus Torvalds pronounces Linux:

Andrew T. Baker - Demystifying Docker - PyCon 2015

How to pronounce Linux

Directory structure

  • /boot: Boot loader files
  • /etc: Configuration files
  • /home: User home directories
  • /root: Root home directory
  • /opt: Third-party applications
  • /dev: Device files
  • /var: Variable files
  • /bin: User binaries
  • /sbin: System binaries
  • /usr: User applications
  • /proc: Process information
  • /mnt: Mount directory
  • /sys: Virtual file system
  • /media: Removeable devices
  • /run: Temporary file system
  • /tmp: Temporary files
  • /lost+found: Recover broken files
  • /lib: System libraries
  • /srv: Service data directory

Changing locale

Edit locale.gen and comment out the locale you need, for example tr_TR.UTF-8 UTF-8

nano /etc/locale.gen

Then run locale-gen command for activation


Changing tzdata (time zone)

dpkg-reconfigure tzdata

Listening live stream

mplayer <stream>
mplayer -nocache -afm ffmpeg <stream>

Some internet radios

Converting video

ffmpeg -i video1.m4v -acodec copy -vcodec copy -f mov

Splitting video

ffmpeg -i ORIGINALFILE.mp4 -acodec copy -vcodec copy -ss START -t LENGTH OUTFILE.mp4

where START is starting positing in seconds or in format hh:mm:ss LENGTH is the chunk length in seconds or in format hh:mm:ss

If let’s say your video is 31 minutes long and you want so split into 15 min chunks here is how you run it:

ffmpeg -i ORIGINALFILE.mp4 -acodec copy -vcodec copy -ss 0 -t 00:15:00 OUTFILE-1.mp4
ffmpeg -i ORIGINALFILE.mp4 -acodec copy -vcodec copy -ss 00:15:00 -t 00:15:00 OUTFILE-2.mp4
ffmpeg -i ORIGINALFILE.mp4 -acodec copy -vcodec copy -ss 00:30:00 -t 00:31:00 OUTFILE-3.mp4


To set home directory

usermod –d /home/user1/

To set root gid and groups for the user1

usermod –g 0 –G 0 user1

To change access rights for a directory

chmod 777 /var/www/directory

To remove package with configuration files

aptitude remove --purge package-name

To remove old configuration files

dpkg --purge package-name

To combine .rar files using unrar

unrar e -kb part01.rar


rarcrack p1r.part1.rar

Creating symbolic link (There is no “/” sign at the end)

ln -s /var/www/existing /var/www/newname

Burning an ISO image to CD-ROM

apt-get install cdrecord

cdrecord -scanbus
... snip ...

1,0,0 100) 'HDT72251' '6DLAT80 ' 'V43O' Disk

1,1,0 101) *

1,2,0 102) *

... snip ...

cdrecord -dev 1,0,0 /tmp/output.iso

Removing kernel

uname –a
dpkg --list 'linux-image*'
sudo aptitude remove linux-image-2.6.18-5-686

Sources List,

nano /etc/apt/sources.list

Trace a program (ex. pidgin)

strace -v -i -s 9999 $( which pidgin ) >| strace.log 2>&1


To check if a port is free, run the following command:

nc localhost 56733 < /dev/null; echo $?

If the output of the command above is 1, then the port is free and usable.

xattr (extended attributes)

Delete ‘Where From’ metadata from files

xattr /Path/To/File

You’ll get a key named To delete this key in the Terminal, run:

xattr -d /Path/To/File

Mount External HDD (NTFS)

Install ntfs-3g library

aptitude install ntfs-3g

Shows all the disk drives

fdisk -l

To make writable mount

mount /dev/sda1 /mnt/sda1 -t ntfs-3g -o rw,umask=0022,uid=dev,gid=dev

Mount NTFS partition

umask is a filter of permissions, so it works in the opposite way to chmod. Full permissions are equivalent to 777 (rwxrwxrwx). A umask of 0222 (-w–w–w-) leaves 555 (r-xr-xr-x).

mount /dev/sda1 /mnt/sda1 -t ntfs -r -o umask=0222,uid=dev,gid=dev

-rwxr-x— 1 dev dev 28096 Aug 24 1996 chkdsk.exe

umount /mnt/sda1/

To make writable mount

mount /dev/sda1 /mnt/sda1 -t ntfs-3g -o rw,umask=0022,uid=dev,gid=dev

Mount an ISO image

Under UNIX and Linux like oses a loop device (a pseudo-device) can make a file accessible as a block device. It is is often used for CD / DVD ISO images and floppy disc images. Mounting a file containing a filesystem via such a loop mount makes the files within that filesystem accessible. They appear in the mount point directory.

Open terminal and create a mount point:

sudo mkdir /home/user/iso

If your iso image is at /tmp/file.iso, type the following to mount it:

sudo mount -o loop /tmp/file.iso /home/user/iso

To unmount type the command:

sudo umount /home/user/iso

Accurate Platform Detection

shtool platform -v -F "%sc (%ac) %st (%at) %sp (%ap)"
cat /etc/*-release

Network Testing Basics

Install netkit-ping, traceroute, dnsutils, ipchains (for 2.2 kernel), iptables (for 2.4 kernel), and net-tools packages and:

ping           # check Internet connection
traceroute     # trace IP packets
ifconfig                  # check host config
route -n                  # check routing config
dig [] host.dom [{a|mx|any}] |less # check host.dom DNS records by for a {a|mx|any} record
ipchains -L -n |less      # check packet filter (2.2 kernel)
iptables -L -n |less      # check packet filter (2.4 kernel)
netstat -a                # find all open ports
netstat -l --inet         # find listening ports
netstat -ln --tcp         # find listening TCP ports (numeric)

How to format a hard drive in linux

To create partition on hard drive B

cfdisk /dev/sdb

Choose New, Primary and then Write and Quit

To format 1st partition on hard drive B

mkfs /dev/sdb1

convert images to pdf

Use convert program (it is an executable installed as part of Imagemagick suite of tools):

convert 'p%d.jpg[1-148]' file.pdf
convert "*.{ext1,ext2,ext3,...}" -quality 100 outfile.pdf

Create favicon.ico

Using netpbm and GIMP

Install netpbm and GIMP

aptitude install netpbm gimp

Step # 1: Convert logo to ppm raw format

  1. Open your logo using GIMP
  2. Now cut and paste logo in square
  3. Next resize logo by visiting Image > Scale image option. Set pixel size to 16 x 16 or 32 x 32 or 48 x 48.
  4. Next click on File > Save as > Enter file name as favicon.ppm > Click on Save > Raw Encoding > Ok

Step # 2: Convert portable pixmaps into a Windows .ico file

ppmtowinicon -output favicon.ico favicon.ppm

Using imagemagick

Install imagemagick first

brew install imagemagick

and use convert tool

convert -background transparent icon.png -define icon:auto-resize=16,32,48,64,256 icon.ico

How to cycle through reverse-i-search in BASH?

To cycle through alternatives by repeatedly hitting Ctrl+R


Ctrl+R grep Ctrl+R Ctrl+R ...

Convert png image to jpg with white background

mogrify -format jpg -background white -flatten *.png


Using the xattr command, you can inspect the extended attributes:

$ xattr s.7z

and use the -d option to delete one extended attribute:

$ xattr -d s.7z
$ xattr s.7z

you can also use the -c option to remove all extended attributes:

$ xattr -c s.7z
$ xattr s.7z

Checking the SHA-256 checksum

You can compare the SHA-256 checksum of your downloaded binary against the checksums that are provided for every release. To generate a SHA-256 checksum of your downloaded binary, then open the corresponding checksum file and ensure that it contains the same number.

$ shasum -a 256 downloaded_binary.tar.gz

Getting all files from a web page using wget

For downloading files from a directory listing, use -r (recursive), -np (don’t follow links to parent directories), and -k to make links in downloaded HTML or CSS point to local files

wget -r -np -k [web_address]

Other useful options:

  • -nd (no directories): download all files to the current directory
  • -e ignore robots.txt files, don’t download robots.txt files
  • -A png,jpg: accept only files with the extensions png or jpg
  • -m (mirror): -r –timestamping –level inf –no-remove-listing
  • -nc, –no-clobber: Skip download if files exist

How to Make a Bootable USB Stick from an ISO File

from Mac

  1. Download the desired file
  2. Convert the .iso file to .img using the convert option of hdiutil:
hdiutil convert -format UDRW -o /path/to/target.img /path/to/source.iso

Note: OS X tends to put the .dmg ending on the output file automatically. Rename the file by typing:

mv /path/to/target.img.dmg /path/to/target.img
  1. Run diskutil list to get the current list of devices
  2. Insert your flash media 5 .Run diskutil list again and determine the device node assigned to your flash media (e.g. /dev/disk2)
  3. Run diskutil unmountDisk /dev/diskN (replace N with the disk number from the last command - in the previous example, N would be 2)

  4. Execute sudo dd if=/path/to/downloaded.img of=/dev/rdiskN bs=1m (replace /path/to/downloaded.img with the path where the image file is located; for example, ./ubuntu.img or ./ubuntu.dmg).

Note: Using /dev/rdisk instead of /dev/disk may be faster.

Note: If you see the error dd: Invalid number ‘1m’, you are using GNU dd. Use the same command but replace bs=1m with bs=1M.

Note: If you see the error dd: /dev/diskN: Resource busy, make sure the disk is not in use. Start the ‘Disk’ and unmount (don’t eject) the drive.

  1. Run diskutil eject /dev/diskN and remove your flash media when the command completes

Now the USB stick is ready. Boot the device that you want from the USB stick.

sha3sum: Keccak, SHA-3, SHAKE, and RawSHAKE checksum utilities

sha3sum somefile.txt > somefile.txt.sha3
cat somefile.txt.sha3
765597429418c1b6e4a0d1ad52f2e3feb39c09e0709290571afad07f  somefile.txt

Log Parsing Cheat Sheet

Log Parsing Cheat Sheet 1

Log Parsing Cheat Sheet 2