<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://aznot.com/index.php?action=history&amp;feed=atom&amp;title=Linux%2FTools</id>
	<title>Linux/Tools - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://aznot.com/index.php?action=history&amp;feed=atom&amp;title=Linux%2FTools"/>
	<link rel="alternate" type="text/html" href="https://aznot.com/index.php?title=Linux/Tools&amp;action=history"/>
	<updated>2026-05-09T17:57:22Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://aznot.com/index.php?title=Linux/Tools&amp;diff=769&amp;oldid=prev</id>
		<title>Kenneth: /* mkfs */</title>
		<link rel="alternate" type="text/html" href="https://aznot.com/index.php?title=Linux/Tools&amp;diff=769&amp;oldid=prev"/>
		<updated>2014-08-18T14:45:27Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;mkfs&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== A ==&lt;br /&gt;
&lt;br /&gt;
=== alias ===&lt;br /&gt;
&lt;br /&gt;
alias: manage command aliases&lt;br /&gt;
&lt;br /&gt;
To list aliases:&lt;br /&gt;
 alias&lt;br /&gt;
 alias [ALIAS]&lt;br /&gt;
 alias -p [ALIAS]&lt;br /&gt;
&lt;br /&gt;
To create alias:&lt;br /&gt;
 alias [ALIAS]=&amp;quot;[COMMAND]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
To remove alias:&lt;br /&gt;
 unalias [ALIAS]&lt;br /&gt;
&lt;br /&gt;
CentOS 5 Examples:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias cp=&amp;#039;cp -i&amp;#039;&lt;br /&gt;
alias l.=&amp;#039;ls -d .* --color=tty&amp;#039;&lt;br /&gt;
alias ll=&amp;#039;ls -l --color=tty&amp;#039;&lt;br /&gt;
alias ls=&amp;#039;ls --color=tty&amp;#039;&lt;br /&gt;
alias mv=&amp;#039;mv -i&amp;#039;&lt;br /&gt;
alias rm=&amp;#039;rm -i&amp;#039;&lt;br /&gt;
alias which=&amp;#039;alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde&amp;#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 alias ls=&amp;#039;ls -CF --color=tty&amp;#039;&lt;br /&gt;
&lt;br /&gt;
To pass a parameter to alias, use a function instead: [http://www.cyberciti.biz/faq/linux-unix-pass-argument-to-alias-command/]&lt;br /&gt;
 function foo() { /path/to/command &amp;quot;$@&amp;quot; ;}&lt;br /&gt;
&lt;br /&gt;
== B ==&lt;br /&gt;
&lt;br /&gt;
=== badblock ===&lt;br /&gt;
&lt;br /&gt;
badblocks - search a device for bad blocks&lt;br /&gt;
&lt;br /&gt;
Non Destructive read test:&lt;br /&gt;
 badblocks -s /dev/sdb&lt;br /&gt;
 # -s show&lt;br /&gt;
&lt;br /&gt;
Destructive write test:&lt;br /&gt;
 badblocks -s -w -t 0xff /dev/sdb&lt;br /&gt;
 # -s show, -w write, -t test pattern&lt;br /&gt;
&lt;br /&gt;
=== bc ===&lt;br /&gt;
&lt;br /&gt;
bc - An arbitrary precision calculator language&lt;br /&gt;
&lt;br /&gt;
Note: Default scale is 0, which means no decimal&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;scale=2 ; 1/2&amp;quot; | bc&lt;br /&gt;
echo &amp;#039;(1 + sqrt(5))/2&amp;#039; | bc -l&lt;br /&gt;
echo &amp;#039;pad=20; min=64; (100*10^6)/((pad+min)*8)&amp;#039; | bc    # This shows max FastE packet rate:&lt;br /&gt;
echo &amp;#039;obase=16; ibase=10; 64206&amp;#039; | bc    # Base conversion (decimal to hexadecimal)&lt;br /&gt;
seq 100 | (tr &amp;#039;\n&amp;#039; +; echo 0) | bc       # Add a column of numbers.&lt;br /&gt;
echo &amp;#039;ibase=16; 2DEC&amp;#039; | bc               # Base conversion (hexadecimal to default decimal)&lt;br /&gt;
echo &amp;#039;obase=16; ibase=10; 64206&amp;#039; | bc    # Base conversion (decimal to hexadecimal)&lt;br /&gt;
echo &amp;#039;obase=10; ibase=16; 2DEC&amp;#039; | bc     # Base conversion (hex to dec)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or just use python!&lt;br /&gt;
 echo &amp;quot;print 10 / 2.0&amp;quot; | python&lt;br /&gt;
&lt;br /&gt;
== C ==&lt;br /&gt;
&lt;br /&gt;
=== cut ===&lt;br /&gt;
&lt;br /&gt;
cut - remove sections from each line of files&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;one,two,three&amp;quot; | cut -f 1 -d &amp;quot;,&amp;quot;  # one&lt;br /&gt;
 echo &amp;quot;one,two,three&amp;quot; | cut -b 1-2  # on&lt;br /&gt;
 echo &amp;quot;one,two,three&amp;quot; | rev | cut -d , -f 1 | rev  # three (last field)&lt;br /&gt;
&lt;br /&gt;
other cool alternatives: [http://stackoverflow.com/questions/4563060/how-to-cut-the-last-field-from-a-shell-string]&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;one two three&amp;quot; | awk &amp;#039;{print $NF}&amp;#039;  # three (last field)&lt;br /&gt;
 echo &amp;quot;one,two,three&amp;quot; | awk -F, &amp;#039;{print $NF}&amp;#039;  # three (last field)&lt;br /&gt;
 echo &amp;quot;/string/to/cut.txt&amp;quot; | awk -F&amp;#039;/&amp;#039; &amp;#039;{for (i=1; i&amp;lt;NF; i++) printf(&amp;quot;%s/&amp;quot;, $i)}&amp;#039;&lt;br /&gt;
 awk -F, &amp;#039;{print $NF}&amp;#039; file&lt;br /&gt;
&lt;br /&gt;
 echo $LINE | grep -o &amp;#039;.*/&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 basename /dev/sdb  # sdb&lt;br /&gt;
 dirname /dev/sdb  # /dev&lt;br /&gt;
&lt;br /&gt;
== D ==&lt;br /&gt;
&lt;br /&gt;
=== dmesg ===&lt;br /&gt;
&lt;br /&gt;
dmesg - print or control the kernel ring buffer&lt;br /&gt;
&lt;br /&gt;
Display kernel ring:&lt;br /&gt;
 dmesg&lt;br /&gt;
&lt;br /&gt;
Clear kernel ring:&lt;br /&gt;
 dmesg -c&lt;br /&gt;
&lt;br /&gt;
Initial kernel ring at boot is saved to:&lt;br /&gt;
 /var/log/dmesg&lt;br /&gt;
&lt;br /&gt;
Kernel ring is also logged to:&lt;br /&gt;
 /var/log/messages&lt;br /&gt;
&lt;br /&gt;
=== du ===&lt;br /&gt;
&lt;br /&gt;
du - estimate file space usage&lt;br /&gt;
:Summarize disk usage of each FILE, recursively for directories.&lt;br /&gt;
&lt;br /&gt;
 du --si&lt;br /&gt;
 du -B M&lt;br /&gt;
 du --max-depth=1&lt;br /&gt;
 du -c dir1 dir2  # combined total&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
Find large files&lt;br /&gt;
&lt;br /&gt;
Print largest files and size in bytes&lt;br /&gt;
 find . -xdev -printf &amp;#039;%s %p\n&amp;#039; |sort -nr | head -20&lt;br /&gt;
&lt;br /&gt;
find out top 10 largest file/directories is taking up the most space in a /var directory/file system:&lt;br /&gt;
 du -a /var | sort -n -r | head -n 10&lt;br /&gt;
&lt;br /&gt;
more human readable output try:&lt;br /&gt;
 du -ks /var | sort -n -r | head -n 10&lt;br /&gt;
&lt;br /&gt;
References:&lt;br /&gt;
* Linux Find Large Files - http://www.cyberciti.biz/faq/find-large-files-linux/&lt;br /&gt;
* How do I find the largest top 10 files and directories on a Linux / UNIX / BSD filesystem? - http://www.cyberciti.biz/faq/how-do-i-find-the-largest-filesdirectories-on-a-linuxunixbsd-filesystem/&lt;br /&gt;
&lt;br /&gt;
== E ==&lt;br /&gt;
&lt;br /&gt;
== F ==&lt;br /&gt;
&lt;br /&gt;
== G ==&lt;br /&gt;
&lt;br /&gt;
== H ==&lt;br /&gt;
&lt;br /&gt;
== I ==&lt;br /&gt;
&lt;br /&gt;
== J ==&lt;br /&gt;
&lt;br /&gt;
== K ==&lt;br /&gt;
&lt;br /&gt;
== L ==&lt;br /&gt;
&lt;br /&gt;
=== less ===&lt;br /&gt;
&lt;br /&gt;
less - opposite of more&lt;br /&gt;
&lt;br /&gt;
 cat /etc/passwd | less&lt;br /&gt;
&lt;br /&gt;
Case insensitivity&lt;br /&gt;
 less -i [FILE]  # --ignore-case&lt;br /&gt;
&lt;br /&gt;
Case sensitivity can be toggled within the program by typing &amp;quot;-i&amp;quot;. [http://www.linux-mag.com/id/4442]&lt;br /&gt;
&lt;br /&gt;
=== ln ===&lt;br /&gt;
&lt;br /&gt;
ln - make links between files&lt;br /&gt;
&lt;br /&gt;
Symbolic link:&lt;br /&gt;
 ln -s [TARGET] [ [LINK] ]&lt;br /&gt;
&lt;br /&gt;
Hard link:&lt;br /&gt;
 ln [TARGET] [ [LINK] ]&lt;br /&gt;
&lt;br /&gt;
Dereference links:&lt;br /&gt;
 readlink [link]  # best option&lt;br /&gt;
 ls -l [link] | awk &amp;#039;{print $11}&amp;#039;  # ok option&lt;br /&gt;
 file [link] | awk &amp;#039;{print $5}  # includes some ugly quotes&lt;br /&gt;
&lt;br /&gt;
To find all hard links to a file:&lt;br /&gt;
 find [BASEPATH] -xdev -samefile [LINK]&lt;br /&gt;
&lt;br /&gt;
=== logger ===&lt;br /&gt;
&lt;br /&gt;
logger - a shell command interface to the syslog(3) system log module&lt;br /&gt;
&lt;br /&gt;
Log message to syslog&lt;br /&gt;
&lt;br /&gt;
 logger &amp;quot;message&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 logger -t DNS-Made-Easy -s &amp;quot;Problem updating DNS record.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 logger -t mail.info test&lt;br /&gt;
&lt;br /&gt;
== M ==&lt;br /&gt;
&lt;br /&gt;
=== mkinitrd ===&lt;br /&gt;
&lt;br /&gt;
mkinitrd - is a compat wrapper, which calls dracut to generate an initramfs&lt;br /&gt;
&lt;br /&gt;
 mkinitrd [image] [kernel-version]&lt;br /&gt;
   -f   # overwrite if image exists&lt;br /&gt;
   -v   # verbose&lt;br /&gt;
&lt;br /&gt;
=== mkfs ===&lt;br /&gt;
&lt;br /&gt;
==== mkfs.vfat ====&lt;br /&gt;
&lt;br /&gt;
Install:&lt;br /&gt;
 yum install dosfstools&lt;br /&gt;
&lt;br /&gt;
vfat:&lt;br /&gt;
 mkfs -t vfat /dev/sdg1&lt;br /&gt;
&lt;br /&gt;
 fdisk /dev/sdb  # n p 1 enter enter t 1 c w (part type: 0b or 0c)&lt;br /&gt;
 mkfs.vfat -F 32 /dev/sdb1    # or mkfs.msdos&lt;br /&gt;
 mkfs.vfat -F 32 /dev/sdb1 -n MOVIES    # or mkfs.msdos&lt;br /&gt;
&lt;br /&gt;
partition type:&lt;br /&gt;
 b  W95 FAT32         # BIOS INT 13 - Partitions up to 2047GB&lt;br /&gt;
 c  W95 FAT32 (LBA)   # Extended-INT13 equivalent of 0b&lt;br /&gt;
&lt;br /&gt;
&amp;quot;0x0b (FAT32 without LBA) uses the old  BIOS INT 13 which means it can address a maximum of 7.8GB disk space&amp;quot; [http://www.linuxquestions.org/questions/linux-general-1/fdisk-created-fat32-partition-which-type-0b-or-0c-643261/]&lt;br /&gt;
&lt;br /&gt;
=== modinfo ===&lt;br /&gt;
&lt;br /&gt;
modinfo - program to show information about a Linux Kernel module&lt;br /&gt;
&lt;br /&gt;
 $ modinfo skge&lt;br /&gt;
 filename:       /lib/modules/2.6.18-92.1.18.el5/kernel/drivers/net/skge.ko&lt;br /&gt;
 version:        1.6&lt;br /&gt;
 license:        GPL&lt;br /&gt;
&lt;br /&gt;
=== mount ===&lt;br /&gt;
&lt;br /&gt;
 mount /dev/sdb1 /mnt&lt;br /&gt;
&lt;br /&gt;
== N ==&lt;br /&gt;
&lt;br /&gt;
=== nice ===&lt;br /&gt;
&lt;br /&gt;
Nice and ReNice&lt;br /&gt;
&lt;br /&gt;
 -20 high priority&lt;br /&gt;
 +19 low priority&lt;br /&gt;
&lt;br /&gt;
A high nice value means a low priority for your process: you are going to be nice. A low or negative value means high priority: you are not very nice. The range of allowable niceness values is -20 to +19. &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;renice&amp;#039;&amp;#039;&amp;#039; [http://www.linux-tutorial.info/modules.php?name=ManPage&amp;amp;sec=8&amp;amp;page=renice]&lt;br /&gt;
:Renice alters the scheduling priority of one or more running processes.&lt;br /&gt;
&lt;br /&gt;
 # change the priority of process ID&amp;#039;s 987 and 32, and all processes owned by users daemon and root.&lt;br /&gt;
 renice +1 987 -u daemon root -p 32&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 $ nice -n 5 ~/bin/longtask   # Lowers priority (raise nice) by 5&lt;br /&gt;
 $ sudo renice -5 8829        # Sets nice value to -5&lt;br /&gt;
 $ sudo renice 5 -u boggs     # Sets nice value of boggs&amp;#039;s procs to 5 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
References:&lt;br /&gt;
* Major Tom, This is Job Control: Acting Nice with the Linux System  - http://www.linuxplanet.com/linuxplanet/tutorials/2116/1/&lt;br /&gt;
* Linux Process Control - http://www.comptechdoc.org/os/linux/usersguide/linux_ugprocesses.html&lt;br /&gt;
* Linux.com :: Influence scheduling priority with nice and renice - http://www.linux.com/archive/feed/58638&lt;br /&gt;
&lt;br /&gt;
=== nohup ===&lt;br /&gt;
&lt;br /&gt;
nohup - run a command immune to hangups, with output to a non-tty&lt;br /&gt;
&lt;br /&gt;
 nohup [APPLICATION] &amp;amp;&lt;br /&gt;
&lt;br /&gt;
Make sure to add the &amp;#039;&amp;amp;&amp;#039; to put the process into the background [http://www.cyberciti.biz/tips/nohup-execute-commands-after-you-exit-from-a-shell-prompt.html], or you will have to do it manually with:&lt;br /&gt;
 [ctrl]+z&lt;br /&gt;
 jobs&lt;br /&gt;
 bg %1&lt;br /&gt;
 &lt;br /&gt;
To nohup a running process: [http://stackoverflow.com/questions/625409/how-do-i-put-an-already-running-process-under-nohup]&lt;br /&gt;
 [ctrl]+z&lt;br /&gt;
 jobs&lt;br /&gt;
 bg %1&lt;br /&gt;
 disown %1&lt;br /&gt;
&lt;br /&gt;
== O ==&lt;br /&gt;
&lt;br /&gt;
== P ==&lt;br /&gt;
&lt;br /&gt;
=== parted ===&lt;br /&gt;
&lt;br /&gt;
GNU Parted - a partition manipulation program&lt;br /&gt;
&lt;br /&gt;
Used by OpenELEC to create SD card partitions: (create_sdcard)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
DISK = /dev/sdh&lt;br /&gt;
&lt;br /&gt;
# writing new disklabel on $DISK (removing all partitions)...&lt;br /&gt;
parted -s /dev/sdh mklabel msdos&lt;br /&gt;
&lt;br /&gt;
# creating partitions on $DISK...&lt;br /&gt;
parted -s &amp;quot;$DISK&amp;quot; unit cyl mkpart primary fat32 -- 0 16&lt;br /&gt;
parted -s &amp;quot;$DISK&amp;quot; unit cyl mkpart primary ext2 -- 16 -2&lt;br /&gt;
&lt;br /&gt;
# make partition active (bootable)&lt;br /&gt;
parted -s &amp;quot;$DISK&amp;quot; set 1 boot on&lt;br /&gt;
&lt;br /&gt;
# tell kernel we have a new partition table&lt;br /&gt;
partprobe &amp;quot;$DISK&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# create filesystem&lt;br /&gt;
# creating filesystem on $PART1...&lt;br /&gt;
mkfs.vfat &amp;quot;$PART1&amp;quot; -I -n System&lt;br /&gt;
# creating filesystem on $PART2...&lt;br /&gt;
mkfs.ext4 &amp;quot;$PART2&amp;quot; -L Storage&lt;br /&gt;
&lt;br /&gt;
# sync disk&lt;br /&gt;
sync&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== printf ===&lt;br /&gt;
&lt;br /&gt;
printf - format and print data&lt;br /&gt;
&lt;br /&gt;
printf:&lt;br /&gt;
 printf &amp;quot;%&amp;#039;.2f&amp;quot; var&lt;br /&gt;
 printf &amp;quot;%&amp;#039;.2d&amp;quot; var&lt;br /&gt;
 printf &amp;quot;Total Rs.%&amp;#039;.2f&amp;quot; var&lt;br /&gt;
 printf &amp;quot;Total $.%&amp;#039;.2f&amp;quot; var&lt;br /&gt;
 printf &amp;quot;%&amp;#039;.2f\n&amp;quot; $x&lt;br /&gt;
&lt;br /&gt;
References:&lt;br /&gt;
* Unix / Linux: Bash Number Currency Formatting Thousands Grouping Separator - http://www.cyberciti.biz/faq/unix-linux-bash-number-formatting-in-with-thousand-separator/&lt;br /&gt;
&lt;br /&gt;
== Q ==&lt;br /&gt;
&lt;br /&gt;
== R ==&lt;br /&gt;
&lt;br /&gt;
== S ==&lt;br /&gt;
&lt;br /&gt;
=== scp ===&lt;br /&gt;
&lt;br /&gt;
 scp file user@host:/some/path/&lt;br /&gt;
 scp user@host:/some/path/file /some/path&lt;br /&gt;
 scp -P 22 file user@host:/some/path/&lt;br /&gt;
 scp -i myidentity file user@host:/some/path/&lt;br /&gt;
&lt;br /&gt;
=== smartctl ===&lt;br /&gt;
&lt;br /&gt;
SMART Tools&lt;br /&gt;
&lt;br /&gt;
[http://smartmontools.sourceforge.net/ Smartmon Tools]&lt;br /&gt;
&lt;br /&gt;
Get Disk Information:&lt;br /&gt;
 smartctl -a /dev/sda&lt;br /&gt;
&lt;br /&gt;
Turn on SMART:&lt;br /&gt;
 smartctl -s on -o on -S on /dev/hda&lt;br /&gt;
 # -s on  # Enable/disable SMART on device (on/off)&lt;br /&gt;
 # -o on  # Enable/disable automatic offline testing on device (on/off)&lt;br /&gt;
 # -S on  # Enable/disable Attribute autosave on device (on/off)&lt;br /&gt;
&lt;br /&gt;
How long has this disk (system) been powered on in total:&lt;br /&gt;
 smartctl -A /dev/sda | grep Power_On_Hours&lt;br /&gt;
&lt;br /&gt;
 smartctl -i /dev/hda&lt;br /&gt;
 smartctl -H /dev/hda&lt;br /&gt;
 smartctl -t short /dev/hda&lt;br /&gt;
 smartctl -l selftest /dev/hda&lt;br /&gt;
&lt;br /&gt;
References:&lt;br /&gt;
*[http://www.linuxjournal.com/content/know-when-your-drives-are-failing-smartd Know when your drives are failing, with smartd | Linux Journal]&lt;br /&gt;
&lt;br /&gt;
=== ssh ===&lt;br /&gt;
&lt;br /&gt;
 ssh user@host&lt;br /&gt;
 ssh user@host some_command&lt;br /&gt;
 ssh -p 22 user@host&lt;br /&gt;
 scp -i myidentity user@host&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
Keep Alive:&lt;br /&gt;
&lt;br /&gt;
 # send keep alive every 30 seconds&lt;br /&gt;
 ssh -o ServerAliveInterval=30 user@host&lt;br /&gt;
&lt;br /&gt;
References:&lt;br /&gt;
*[http://madphilosopher.ca/2005/07/an-ssh-keep-alive-tip/ An ssh keep-alive tip]&lt;br /&gt;
*[http://ubuntu.wordpress.com/2006/02/03/keeping-ssh-sessions-alive/ Keeping SSH Sessions Alive  ]&lt;br /&gt;
*[http://www.brandonhutchinson.com/OpenSSH_ClientAliveInterval.html OpenSSH ClientAliveInterval]&lt;br /&gt;
*[http://lists.maemo.org/pipermail//maemo-users/2007-May/005336.html Slow SSH connect to N800 (ServerAliveInterval)]&lt;br /&gt;
*[http://drupal.star.bnl.gov/STAR/comp/sofi/facility-access/ssh-stable-con/ SSH connection stability]&lt;br /&gt;
&lt;br /&gt;
=== strace ===&lt;br /&gt;
&lt;br /&gt;
strace - trace system calls and signals&lt;br /&gt;
&lt;br /&gt;
List files opened by command:&lt;br /&gt;
 strace -e trace=open vmkload_mod -s iomemory-vsl &amp;gt; /dev/null&lt;br /&gt;
&lt;br /&gt;
Summarise/profile system calls made by command:&lt;br /&gt;
 strace -c ls &amp;gt;/dev/null&lt;br /&gt;
&lt;br /&gt;
List system calls made by command:&lt;br /&gt;
 strace -f -e open ls &amp;gt;/dev/null&lt;br /&gt;
&lt;br /&gt;
== T ==&lt;br /&gt;
&lt;br /&gt;
=== tar ===&lt;br /&gt;
&lt;br /&gt;
tar - GNU ‘tar’ saves many files together into a single tape or disk archive, and can restore individual files from the archive.&lt;br /&gt;
&lt;br /&gt;
List tar contents:&lt;br /&gt;
 tar -tf file.tar&lt;br /&gt;
&lt;br /&gt;
Build tar:&lt;br /&gt;
 tar -cf file.tar  file1 file2 file3&lt;br /&gt;
 tar -cf file.tar  folder1&lt;br /&gt;
 tar -cf file.tar  -C folder1  .     # chdir, so don&amp;#039;t include folder in tar&lt;br /&gt;
 cd folder1 ; tar -cf ../file.tar *  # build tar of current folder, but don&amp;#039;t include&lt;br /&gt;
 tar -cf file.tar  *                 # make archive of all files, will have issues second run&lt;br /&gt;
&lt;br /&gt;
Extract tar:&lt;br /&gt;
 tar -xf file.tar&lt;br /&gt;
 tar -xf file.tar  file1           # only extract file1&lt;br /&gt;
 tar -xf file.tar  -C folder1      # chdir, then extract&lt;br /&gt;
&lt;br /&gt;
Options:&lt;br /&gt;
 -h, --dereference	# dereference links: (copy actual file, not link)&lt;br /&gt;
 -A, --catenate, --concatenate	# append tar files to an archive&lt;br /&gt;
 -c, --create		#create a new archive&lt;br /&gt;
 -t, --list		#list the contents of an archive&lt;br /&gt;
 -u, --update		#only append files that are newer than the existing in archive&lt;br /&gt;
 -x, --extract, --get	#extract files from an archive&lt;br /&gt;
 -C, --directory DIR	# change to directory DIR&lt;br /&gt;
&lt;br /&gt;
Excludes:&lt;br /&gt;
 # archive&lt;br /&gt;
 tar --exclude=&amp;#039;./folder&amp;#039; --exclude=&amp;#039;./upload/folder2&amp;#039; somefolder -zcvf /backup/deploy.tgz&lt;br /&gt;
 # extract&lt;br /&gt;
 tar -xvf deploy.tgz --exclude &amp;#039;.htaccess&amp;#039;&lt;br /&gt;
&lt;br /&gt;
=== time ===&lt;br /&gt;
&lt;br /&gt;
time: time a process&lt;br /&gt;
&lt;br /&gt;
Time a process:&lt;br /&gt;
 time [process]&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
 $ time sleep 10&lt;br /&gt;
 real    0m10.006s&lt;br /&gt;
 user    0m0.001s&lt;br /&gt;
 sys     0m0.003s&lt;br /&gt;
&lt;br /&gt;
Capture time:&lt;br /&gt;
 $ ( time sleep 10 ) 2&amp;gt;&amp;amp;1 1&amp;gt;/dev/null | grep real | awk &amp;#039;{print $2}&amp;#039; &lt;br /&gt;
 0m10.011s&lt;br /&gt;
&lt;br /&gt;
Convert to Seconds:&lt;br /&gt;
 OUTPUT=$( ( time staf $IPPREFIX$1 ping ping ) 2&amp;gt;&amp;amp;1 )&lt;br /&gt;
 FULLTIME=$( echo &amp;quot;$OUTPUT&amp;quot; | grep real | awk &amp;#039;{print $2}&amp;#039; | awk -F . &amp;#039;{ print $1 }&amp;#039; )&lt;br /&gt;
 MTIME=$( echo $FULLTIME | awk -F &amp;#039;m&amp;#039; &amp;#039;{print $1}&amp;#039; )&lt;br /&gt;
 STIME=$( echo $FULLTIME | awk -F &amp;#039;m&amp;#039; &amp;#039;{print $2}&amp;#039; )&lt;br /&gt;
 TOTAL_SECONDS=$(( $MTIME * 60 + $STIME ))&lt;br /&gt;
&lt;br /&gt;
=== touch ===&lt;br /&gt;
&lt;br /&gt;
touch - change file timestamps&lt;br /&gt;
&lt;br /&gt;
create file:&lt;br /&gt;
 touch [file]&lt;br /&gt;
&lt;br /&gt;
set file time:&lt;br /&gt;
 touch -c -t 0304050607 [file]&lt;br /&gt;
&lt;br /&gt;
 touch -d &amp;quot;2004-02-27 14:19:13.489392193 +0530&amp;quot; [file]&lt;br /&gt;
 touch --date=&amp;quot;2004-02-27 14:19:13.489392193 +0530&amp;quot; [file]&lt;br /&gt;
 touch --date &amp;quot;2004-02-27 0:0:0&amp;quot; [file]  # 1 hour behind?&lt;br /&gt;
&lt;br /&gt;
=== tr ===&lt;br /&gt;
&lt;br /&gt;
tr - translate or delete characters&lt;br /&gt;
&lt;br /&gt;
Convert to upper or lower case:&lt;br /&gt;
 ... | tr [:lower:] [:upper:]&lt;br /&gt;
 ... | tr [:upper:] [:lower:]&lt;br /&gt;
&lt;br /&gt;
=== tree ===&lt;br /&gt;
&lt;br /&gt;
tree - list contents of directories in a tree-like format.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Directory tree:&lt;br /&gt;
 tree&lt;br /&gt;
&lt;br /&gt;
Shell script way: [http://www.centerkey.com/tree/]&lt;br /&gt;
 ls -R | grep &amp;quot;:$&amp;quot; | sed -e &amp;#039;s/:$//&amp;#039; -e &amp;#039;s/[^-][^\/]*\//--/g&amp;#039; -e &amp;#039;s/^/   /&amp;#039; -e &amp;#039;s/-/|/&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Output as CSV file: [http://www.linuxquestions.org/questions/linux-software-2/utility-needed-list-folder-tree-and-files-in-text-file-501817/]&lt;br /&gt;
 find | sed -e&amp;#039;s/&amp;quot;/\\&amp;quot;/g&amp;#039; -e&amp;#039;s/^..//&amp;#039; -e&amp;#039;s/\//&amp;quot;,&amp;quot;/g&amp;#039; -e&amp;#039;s/^/&amp;quot;/&amp;#039; -e&amp;#039;s/$/&amp;quot;/&amp;#039; &amp;gt; /tmp/listing.csv&lt;br /&gt;
&lt;br /&gt;
http://www.centerkey.com/tree/tree.sh:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#######################################################&lt;br /&gt;
#  UNIX TREE                                          #&lt;br /&gt;
#  Version: 2.3                                       #&lt;br /&gt;
#  File: ~/apps/tree/tree.sh                          #&lt;br /&gt;
#                                                     #&lt;br /&gt;
#  Displays Structure of Directory Hierarchy          #&lt;br /&gt;
#  -------------------------------------------------  #&lt;br /&gt;
#  This tiny script uses &amp;quot;ls&amp;quot;, &amp;quot;grep&amp;quot;, and &amp;quot;sed&amp;quot;      #&lt;br /&gt;
#  in a single command to show the nesting of         #&lt;br /&gt;
#  sub-directories.  The setup command for PATH       #&lt;br /&gt;
#  works with the Bash shell (the Mac OS X default).  #&lt;br /&gt;
#                                                     #&lt;br /&gt;
#  Setup:                                             #&lt;br /&gt;
#     $ cd ~/apps/tree                                #&lt;br /&gt;
#     $ chmod u+x tree.sh                             #&lt;br /&gt;
#     $ ln -s ~/apps/tree/tree.sh ~/bin/tree          #&lt;br /&gt;
#     $ echo &amp;quot;PATH=~/bin:\${PATH}&amp;quot; &amp;gt;&amp;gt; ~/.profile      #&lt;br /&gt;
#                                                     #&lt;br /&gt;
#  Usage:                                             #&lt;br /&gt;
#     $ tree [directory]                              #&lt;br /&gt;
#                                                     #&lt;br /&gt;
#  Examples:                                          #&lt;br /&gt;
#     $ tree                                          #&lt;br /&gt;
#     $ tree /etc/opt                                 #&lt;br /&gt;
#     $ tree ..                                       #&lt;br /&gt;
#                                                     #&lt;br /&gt;
#  Public Domain Software -- Free to Use as You Like  #&lt;br /&gt;
#  http://www.centerkey.com/tree  -  By Dem Pilafian  #&lt;br /&gt;
#######################################################&lt;br /&gt;
&lt;br /&gt;
echo&lt;br /&gt;
if [ &amp;quot;$1&amp;quot; != &amp;quot;&amp;quot; ] #if parameter exists, use as base folder&lt;br /&gt;
  then cd &amp;quot;$1&amp;quot;&lt;br /&gt;
  fi&lt;br /&gt;
pwd&lt;br /&gt;
ls -R | grep &amp;quot;:$&amp;quot; | \&lt;br /&gt;
  sed -e &amp;#039;s/:$//&amp;#039; -e &amp;#039;s/[^-][^\/]*\//--/g&amp;#039; -e &amp;#039;s/^/ /&amp;#039; -e &amp;#039;s/-/|/&amp;#039;&lt;br /&gt;
# 1st sed: remove colons&lt;br /&gt;
# 2nd sed: replace higher level folder names with dashes&lt;br /&gt;
# 3rd sed: indent graph three spaces&lt;br /&gt;
# 4th sed: replace first dash with a vertical bar&lt;br /&gt;
if [ `ls -F -1 | grep &amp;quot;/&amp;quot; | wc -l` = 0 ]  # check if no folders&lt;br /&gt;
  then echo &amp;quot; -&amp;gt; no sub-directories&amp;quot;&lt;br /&gt;
  fi&lt;br /&gt;
echo&lt;br /&gt;
exit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== U ==&lt;br /&gt;
&lt;br /&gt;
=== ulimit ===&lt;br /&gt;
&lt;br /&gt;
ulimit - Provides control over the resources available to the shell and to processes started by it, on systems that allow such control.&lt;br /&gt;
&lt;br /&gt;
The default maximum open files (file descriptors) on a Redhat Linux system is 1024 per session.  This is set here:&lt;br /&gt;
 /etc/security/limits.d/90-nproc.conf&lt;br /&gt;
&lt;br /&gt;
See all of the current soft limits: [http://www.eriephillips.com/?q=node/4]&lt;br /&gt;
 ulimit -a&lt;br /&gt;
 ulimit -Sa&lt;br /&gt;
&lt;br /&gt;
See all of the current hard limits: [http://www.eriephillips.com/?q=node/4]&lt;br /&gt;
 ulimit -Ha&lt;br /&gt;
&lt;br /&gt;
To see the current session limit:&lt;br /&gt;
 ulimit -n&lt;br /&gt;
&lt;br /&gt;
To see the system limit:&lt;br /&gt;
 cat /proc/sys/fs/file-max&lt;br /&gt;
&lt;br /&gt;
To set the max to half the system limit:&lt;br /&gt;
 ulimit -n $(( `cat /proc/sys/fs/file-max` / 2 ))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Umlimited?&lt;br /&gt;
&lt;br /&gt;
The system file descriptor limit is set in /proc/sys/fs/file-max. The following command will increase the limit to 65535:&lt;br /&gt;
 echo 65535 &amp;gt; /proc/sys/fs/file-max&lt;br /&gt;
&lt;br /&gt;
You should then be able to increase the file descriptor limits using:&lt;br /&gt;
 ulimit -n unlimited&lt;br /&gt;
&lt;br /&gt;
This did not work for me.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A bash forkbomb [http://www.linuxhowtos.org/Tips%20and%20Tricks/ulimit.htm]&lt;br /&gt;
 $ :(){ :|:&amp;amp; };:&lt;br /&gt;
&lt;br /&gt;
References:&lt;br /&gt;
*[http://www.cyberciti.biz/faq/linux-increase-the-maximum-number-of-open-files/ Linux increase the maximum number of open files or file descriptors]&lt;br /&gt;
*[http://www.xenoclast.org/doc/benchmark/HTTP-benchmarking-HOWTO/node7.html Performance tuning]&lt;br /&gt;
*[http://www.linuxhowtos.org/Tips%20and%20Tricks/ulimit.htm Linux Howtos: Tips and Tricks -&amp;gt; ulimit and sysctl]&lt;br /&gt;
&lt;br /&gt;
== V ==&lt;br /&gt;
&lt;br /&gt;
== W ==&lt;br /&gt;
&lt;br /&gt;
== X ==&lt;br /&gt;
&lt;br /&gt;
== Y ==&lt;br /&gt;
&lt;br /&gt;
== Z ==&lt;br /&gt;
&lt;br /&gt;
== keywords ==&lt;br /&gt;
&lt;br /&gt;
[[Category:Linux]]&lt;/div&gt;</summary>
		<author><name>Kenneth</name></author>
	</entry>
</feed>