<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>WiredRevolution.com &#187; commands</title>
	<atom:link href="http://www.wiredrevolution.com/category/commands/feed" rel="self" type="application/rss+xml" />
	<link>http://www.wiredrevolution.com</link>
	<description>A Bit of Linux Wisdom</description>
	<lastBuildDate>Sat, 22 May 2010 16:03:56 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Download digital camera photos with gphoto2</title>
		<link>http://www.wiredrevolution.com/commands/download-digital-camera-photos-with-gphoto2</link>
		<comments>http://www.wiredrevolution.com/commands/download-digital-camera-photos-with-gphoto2#comments</comments>
		<pubDate>Sat, 29 Nov 2008 22:14:44 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[commands]]></category>
		<category><![CDATA[avi]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[digital camera]]></category>
		<category><![CDATA[gentoo]]></category>
		<category><![CDATA[gphoto2]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[jpg]]></category>
		<category><![CDATA[movies]]></category>
		<category><![CDATA[mpg]]></category>
		<category><![CDATA[pictures]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[USB]]></category>

		<guid isPermaLink="false">http://www.wiredrevolution.com/?p=786</guid>
		<description><![CDATA[<img src="http://www.wiredrevolution.com/wp-content/uploads/commands_icon.png" width="80" height="69" alt="" title="commands" /><br/>gphoto2 allows you to directly connect a digital camera over USB and transfer the saved images and videos to your computer. This is very helpful when you don&#8217;t have access to a media card reader.
Install the gphoto2 package on your system.
In Gentoo:

# emerge media-gfx/gphoto2

In Ubuntu:

# aptitude install gphoto2

Start off by connecting your digital camera to [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<img src="http://www.wiredrevolution.com/wp-content/uploads/commands_icon.png" width="80" height="69" alt="" title="commands" /><br/><p><strong>gphoto2</strong> allows you to directly connect a digital camera over USB and transfer the saved images and videos to your computer. This is very helpful when you don&#8217;t have access to a media card reader.</p>
<p>Install the gphoto2 package on your system.</p>
<p>In <strong>Gentoo</strong>:</p>
<pre>
# emerge media-gfx/gphoto2
</pre>
<p>In <strong>Ubuntu</strong>:</p>
<pre>
# aptitude install gphoto2
</pre>
<p>Start off by connecting your digital camera to your computer with a USB cable and turning on any transfer/playback mode that might exist.</p>
<p>Run the following command to see if your camera is auto-detected by gphoto2. It will show you the camera model that detected and what port it is on.</p>
<pre>
$ gphoto2 --auto-detect
</pre>
<p>This will show you all the files that are currently stored on your camera including images and videos. You will get data such as type, size, and location on the camera device.</p>
<pre>
$ gphoto2 --list-files
</pre>
<p>Change your current working directory to the location that you want the images saved on your system. </p>
<pre>
$ cd ~/camera_images/
</pre>
<p>Now you can download all the images and videos from your camera to your current working directory on your system.</p>
<pre>
$ gphoto2 --get-all-files
</pre>
<p>Once all images are downloaded to your computer you can clear the camera. Make sure your images are stored on your system correctly because there is no going back.</p>
<pre>
$ gphoto2 --delete-all-files
</pre>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.wiredrevolution.com/commands/download-digital-camera-photos-with-gphoto2/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>List all open files with lsof</title>
		<link>http://www.wiredrevolution.com/commands/list-all-open-files-with-lsof</link>
		<comments>http://www.wiredrevolution.com/commands/list-all-open-files-with-lsof#comments</comments>
		<pubDate>Sat, 25 Oct 2008 04:32:10 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[commands]]></category>
		<category><![CDATA[lsof]]></category>
		<category><![CDATA[sudo]]></category>

		<guid isPermaLink="false">http://www.wiredrevolution.com/?p=496</guid>
		<description><![CDATA[<img src="http://www.wiredrevolution.com/wp-content/uploads/commands_icon.png" width="80" height="69" alt="" title="commands" /><br/>The lsof command stands for &#8220;list open files&#8221;. It can show all open files as well as sockets, memory mapped libraries, directories, pipes, and network sockets.  It is an incredibly powerful tool which you can use to gather detailed information about what is happening on your system.
If you run lsof as a normal user [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<img src="http://www.wiredrevolution.com/wp-content/uploads/commands_icon.png" width="80" height="69" alt="" title="commands" /><br/><p>The lsof command stands for &#8220;list open files&#8221;. It can show all open files as well as sockets, memory mapped libraries, directories, pipes, and network sockets.  It is an incredibly powerful tool which you can use to gather detailed information about what is happening on your system.</p>
<p>If you run lsof as a normal user you will be limited to only the the processes owned by that user.  To get system wide results you must run the command as root or <a href="/commands/submit-commands-as-root-with-sudo">use sudo</a>.</p>
<p>Running the command by itself will show information for all active process on the system.</p>
<pre>
# lsof
</pre>
<pre>
COMMAND    PID   USER   FD      TYPE             DEVICE     SIZE       NODE NAME
lsof    7289 root  cwd    DIR    8,3    4096  6504451 /home/ryan
lsof    7289 root  rtd    DIR    8,3    4096        2 /
lsof    7289 root  txt    REG    8,3  110280 11178207 /usr/bin/lsof
lsof    7289 root  mem    REG    8,3  114952 11504968 /lib64/ld-2.6.1.so
lsof    7289 root  mem    REG    8,3 1293456 11504986 /lib64/libc-2.6.1.so
lsof    7289 root    0u   CHR  136,1                3 /dev/pts/1
lsof    7289 root    1u   CHR  136,1                3 /dev/pts/1
lsof    7289 root    2u   CHR  136,1                3 /dev/pts/1
lsof    7289 root    3r   DIR    0,3       0        1 /proc
lsof    7289 root    4r   DIR    0,3       0    19745 /proc/7289/fd
lsof    7289 root    5w  FIFO    0,5            19759 pipe
lsof    7289 root    6r  FIFO    0,5            19760 pipe
lsof    7290 root  cwd    DIR    8,3    4096  6504451 /home/ryan
lsof    7290 root  rtd    DIR    8,3    4096        2 /
lsof    7290 root  txt    REG    8,3  110280 11178207 /usr/bin/lsof
lsof    7290 root  mem    REG    8,3  114952 11504968 /lib64/ld-2.6.1.so
lsof    7290 root  mem    REG    8,3 1293456 11504986 /lib64/libc-2.6.1.so
lsof    7290 root    4r  FIFO    0,5            19759 pipe
lsof    7290 root    7w  FIFO    0,5            19760 pipe
...
</pre>
<p>As you can see in the previous output each open file is associated with its program and PID and has many attributes such as type, size, file descriptor, device, and inode number.</p>
<p>You can narrow the results down to an individual process.</p>
<pre>
# lsof -p 12345
</pre>
<p>You can get results for every process that is owned by a specific user.</p>
<pre>
# lsof -u ryan
</pre>
<p>This will give you detailed information about all network socket connections.</p>
<pre>
# lsof -i
</pre>
<p>You can narrow the results down to only TCP connections.</p>
<pre>
# lsof -i TCP
</pre>
<p>You can get information on a specific port.</p>
<pre>
# lsof -i :80
</pre>
<p>You can get information about all instances of a specific program </p>
<pre>
# lsof -c bash
</pre>
<p>This will show all files that are open within the &#8216;/tmp&#8217; directory.</p>
<pre>
# lsof +D /tmp
</pre>
<p>To get even more detailed output you can pipe these results to grep or use the &#8216;<strong>-a</strong>&#8216; option which combines any number of options.</p>
<p>For example you can view all network socket connections that are owned by the user ryan.</p>
<pre>
# lsof -a -i TCP -u ryan
</pre>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.wiredrevolution.com/commands/list-all-open-files-with-lsof/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Search for files with the find command</title>
		<link>http://www.wiredrevolution.com/commands/search-for-files-with-the-find-command</link>
		<comments>http://www.wiredrevolution.com/commands/search-for-files-with-the-find-command#comments</comments>
		<pubDate>Mon, 20 Oct 2008 12:46:21 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[commands]]></category>
		<category><![CDATA[find]]></category>
		<category><![CDATA[locate]]></category>
		<category><![CDATA[search]]></category>

		<guid isPermaLink="false">http://www.wiredrevolution.com/?p=332</guid>
		<description><![CDATA[<img src="http://www.wiredrevolution.com/wp-content/uploads/commands_icon.png" width="80" height="69" alt="" title="commands" /><br/>The find command allows you to recursively search and locate files on your system based on specific criteria. You can search by name, owner, group, type, permissions, date, as well as many others.
The find command uses the following format:

find [search_path(s)] [search_criteria]

The following is the most basic way to run the find command. It will list [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<img src="http://www.wiredrevolution.com/wp-content/uploads/commands_icon.png" width="80" height="69" alt="" title="commands" /><br/><p>The find command allows you to recursively search and locate files on your system based on specific criteria. You can search by name, owner, group, type, permissions, date, as well as many others.</p>
<p>The find command uses the following format:</p>
<pre>
find [search_path(s)] [search_criteria]
</pre>
<p>The following is the most basic way to run the find command. It will list every file and directory within your current working directory.</p>
<pre>
$ find
</pre>
<p>This produces the same output but you are specifically listing the current directory as the search path.</p>
<pre>
$ find .
</pre>
<p>To search the entire filesystem, specify root as the search path (this could take a long time). </p>
<pre>
$ find /
</pre>
<p>You may want to <a href="/programming/bash-programming/io-redirection-in-bash">redirect stderr</a> to &#8220;<strong>/dev/null</strong>&#8221; to separate the valid output from the errors you might encounter from searching in directories where you don&#8217;t have the correct permissions.</p>
<pre>
$ find / 2> /dev/null
</pre>
<p>To search for a file with a specific name. This will find all files named &#8220;myfile&#8221; within your home directory.</p>
<pre>
$ find ~/ -name myfile
</pre>
<p>This will find all files with a &#8220;.jpg&#8221; extension in your home directory.  The double quotes are needed so the shell will not expand the wildcards in the search string before it passes it to the find command.</p>
<pre>
$ find ~/ -name "*.jpg"
</pre>
<p>You can limit the depth level of the search as well. Set the value to 1 to search within the specified directory without recursing into any subdirectories.  Raising the value will extend the search into that many directory levels.</p>
<pre>
$ find ~/ -name "*.jpg" -maxdepth 1
</pre>
<p>Search for files by permissions. This will find all files in your home directory that have <strong>rwx</strong> permissions for everyone.</p>
<pre>
$ find ~/ -perm 777
</pre>
<p>Search for executables.</p>
<pre>
$ find ~/ -executable
</pre>
<p>Search for files in your home directory which have been modified in the last twenty-four hours.</p>
<pre>
$ find ~/ -mtime 0
</pre>
<p>Search for files that are owned by the user &#8220;ryan&#8221;.</p>
<pre>
$ find / -user ryan
</pre>
<p>The find command is great for locating files but you can also execute commands on those files that it finds.  To execute commands use the &#8216;<strong>-exec</strong>&#8216; option.  The command below will perform an &#8216;<strong>ls -l</strong>&#8216; on each jpeg file it finds in your home directory.</p>
<pre>
$ find ~/ -name "*.jpg" -exec ls -l {} \;
</pre>
<p>The &#8216;<strong>-ok</strong>&#8216; option is similar to &#8216;<strong>-exec</strong>&#8216; but it will prompt you for confirmation before executing each command. This is helpful when you want to execute a potentially dangerous command such as removing files with <strong>rm</strong> like the example below.</p>
<pre>
$ find ~/ -name "*.jpg" -ok rm {} \;
</pre>
<pre>
< rm ... /home/ryan/pic1.jpg > ? n
< rm ... /home/ryan/pic2.jpg > ? n
< rm ... /home/ryan/pic3.jpg > ? n
</pre>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.wiredrevolution.com/commands/search-for-files-with-the-find-command/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>View dynamic library dependencies with ldd</title>
		<link>http://www.wiredrevolution.com/commands/view-dynamic-library-dependencies-with-ldd</link>
		<comments>http://www.wiredrevolution.com/commands/view-dynamic-library-dependencies-with-ldd#comments</comments>
		<pubDate>Fri, 17 Oct 2008 12:49:15 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[commands]]></category>
		<category><![CDATA[dl_open]]></category>
		<category><![CDATA[dynamic library]]></category>
		<category><![CDATA[ELF]]></category>
		<category><![CDATA[ld.so]]></category>
		<category><![CDATA[ldd]]></category>
		<category><![CDATA[LD_LIBRARY_PATH]]></category>

		<guid isPermaLink="false">http://www.wiredrevolution.com/?p=377</guid>
		<description><![CDATA[<img src="http://www.wiredrevolution.com/wp-content/uploads/commands_icon.png" width="80" height="69" alt="" title="commands" /><br/>The ldd command allows you to view detailed information about library dependencies of dynamically linked programs and other shared libraries. ldd uses the runtime linker ld.so which reads the ELF formatted executable to generate the output. It is a helpful tool to have at your disposal when debugging broken programs.
Here ldd examines the &#8216;ls&#8217; executable. [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<img src="http://www.wiredrevolution.com/wp-content/uploads/commands_icon.png" width="80" height="69" alt="" title="commands" /><br/><p>The ldd command allows you to view detailed information about library dependencies of dynamically linked programs and other shared libraries. ldd uses the runtime linker <strong>ld.so</strong> which reads the <strong>ELF</strong> formatted executable to generate the output. It is a helpful tool to have at your disposal when debugging broken programs.</p>
<p>Here ldd examines the &#8216;ls&#8217; executable. The output displays the dependencies as well as how they will be resolved if run with the current environment.</p>
<pre>
$ ldd /bin/ls
</pre>
<pre>
	linux-vdso.so.1 =>  (0x00007fffe0dfe000)
	librt.so.1 => /lib/librt.so.1 (0x00002b4eca08e000)
	libacl.so.1 => /lib/libacl.so.1 (0x00002b4eca297000)
	libc.so.6 => /lib/libc.so.6 (0x00002b4eca49f000)
	libpthread.so.0 => /lib/libpthread.so.0 (0x00002b4eca7df000)
	/lib64/ld-linux-x86-64.so.2 (0x00002b4ec9e72000)
	libattr.so.1 => /lib/libattr.so.1 (0x00002b4eca9fa000)
</pre>
<p>Sometimes you will see that an application can&#8217;t resolve one or more libraries. It would most likely fail to execute at this moment if you see a &#8220;not found&#8221; entry like this.</p>
<pre>
$ ldd ~/myprogram
</pre>
<pre>
	librt.so.1 => /lib/librt.so.1 (0x00002b4eca08e000)
	libc.so.6 => /lib/libc.so.6 (0x00002b4eca49f000)
	libpthread.so.0 => /lib/libpthread.so.0 (0x00002b4eca7df000)
	/lib64/ld-linux-x86-64.so.2 (0x00002b4ec9e72000)
	libmylib.so.1 => not found
</pre>
<p>To resolve these type of issues you can either install the missing libraries, or if they are already installed, update the <a href="/system-administration/how-to-correctly-use-ld_library_path">LD_LIBRARY_PATH environment variable</a> with the path to the libraries.</p>
<p>Once you have done one of these two things, rerun ldd on the executable and verify that the library dependency can now be correctly resolved.</p>
<p>One last caveat, ldd will not display information about shared libraries that the program may try to open using the <strong>glibc</strong> function <strong>dl_open</strong>() during its execution.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.wiredrevolution.com/commands/view-dynamic-library-dependencies-with-ldd/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Display the first part of a file with head</title>
		<link>http://www.wiredrevolution.com/commands/display-the-first-part-of-a-file-with-head</link>
		<comments>http://www.wiredrevolution.com/commands/display-the-first-part-of-a-file-with-head#comments</comments>
		<pubDate>Tue, 14 Oct 2008 12:03:22 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[commands]]></category>
		<category><![CDATA[head]]></category>
		<category><![CDATA[tail]]></category>

		<guid isPermaLink="false">http://www.wiredrevolution.com/?p=310</guid>
		<description><![CDATA[<img src="http://www.wiredrevolution.com/wp-content/uploads/commands_icon.png" width="80" height="69" alt="" title="commands" /><br/>Similar to the tail command which shows you the last few lines of a text file, the head command lets you to quickly view the first few lines.
The head command syntax.

head [options] file

By default head will show you the first 10 lines of a text file.

$ head textfile.txt

You can change the number of lines displayed [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<img src="http://www.wiredrevolution.com/wp-content/uploads/commands_icon.png" width="80" height="69" alt="" title="commands" /><br/><p>Similar to <a href="/commands/display-the-last-part-of-a-file-with-tail">the tail command</a> which shows you the last few lines of a text file, the head command lets you to quickly view the first few lines.</p>
<p>The head command syntax.</p>
<pre>
head [options] <em>file</em>
</pre>
<p>By default head will show you the first 10 lines of a text file.</p>
<pre>
$ head textfile.txt
</pre>
<p>You can change the number of lines displayed by adding &#8216;<strong>-n</strong>&#8216; option and adding the number of lines.</p>
<pre>
$ head -n 3 textfile.txt
</pre>
<p>This will show the first 3 lines in the file.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.wiredrevolution.com/commands/display-the-first-part-of-a-file-with-head/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Display the last part of a file with tail</title>
		<link>http://www.wiredrevolution.com/commands/display-the-last-part-of-a-file-with-tail</link>
		<comments>http://www.wiredrevolution.com/commands/display-the-last-part-of-a-file-with-tail#comments</comments>
		<pubDate>Tue, 14 Oct 2008 11:40:48 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[commands]]></category>
		<category><![CDATA[head]]></category>
		<category><![CDATA[tail]]></category>

		<guid isPermaLink="false">http://www.wiredrevolution.com/?p=302</guid>
		<description><![CDATA[<img src="http://www.wiredrevolution.com/wp-content/uploads/commands_icon.png" width="80" height="69" alt="" title="commands" /><br/>Similar to the head command which shows you the first few lines of a text file, the tail command lets you to quickly view the last few lines of a text file. It also supports a monitoring mode which displays ongoing changes within the file.
The tail command syntax.

tail [options] file

By default tail will show you [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<img src="http://www.wiredrevolution.com/wp-content/uploads/commands_icon.png" width="80" height="69" alt="" title="commands" /><br/><p>Similar to <a href="/commands/display-the-first-part-of-a-file-with-head">the head command</a> which shows you the first few lines of a text file, the tail command lets you to quickly view the last few lines of a text file. It also supports a monitoring mode which displays ongoing changes within the file.</p>
<p>The tail command syntax.</p>
<pre>
tail [options] <em>file</em>
</pre>
<p>By default tail will show you the last 10 lines of a text file.</p>
<pre>
$ tail textfile.txt
</pre>
<p>You can change the number of lines displayed by adding &#8216;<strong>-n</strong>&#8216; option and adding the number of lines.</p>
<pre>
$ tail -n 3 textfile.txt
</pre>
<p>This will show the last 3 lines in the file.</p>
<p>You can keep track of ongoing changes within the file by turning on monitoring mode with the &#8216;<strong>-f</strong>&#8216; option.  It is especially helpful when you want to keep an eye on log files.</p>
<pre>
$ tail -f /var/log/syslog
</pre>
<p>As lines are appended to the log file they are also displayed by tail.</p>
<p>You can exit the program by pressing Ctrl-C.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.wiredrevolution.com/commands/display-the-last-part-of-a-file-with-tail/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Determine file type with the file command</title>
		<link>http://www.wiredrevolution.com/commands/determine-file-type-with-the-file-command</link>
		<comments>http://www.wiredrevolution.com/commands/determine-file-type-with-the-file-command#comments</comments>
		<pubDate>Wed, 08 Oct 2008 13:11:43 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[commands]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[magic number]]></category>

		<guid isPermaLink="false">http://www.wiredrevolution.com/?p=247</guid>
		<description><![CDATA[<img src="http://www.wiredrevolution.com/wp-content/uploads/commands_icon.png" width="80" height="69" alt="" title="commands" /><br/>The file command identifies the type or format of a file.  It is a very handy command that can show you how to approach a file when the format is unknown. There are a variety of tests that it uses to determine its type, these tests include a filesystem test, magic number test, and [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<img src="http://www.wiredrevolution.com/wp-content/uploads/commands_icon.png" width="80" height="69" alt="" title="commands" /><br/><p>The file command identifies the type or format of a file.  It is a very handy command that can show you how to approach a file when the format is unknown. There are a variety of tests that it uses to determine its type, these tests include a filesystem test, magic number test, and language tests. The first successful test is the one that is printed to the user.</p>
<p>The <strong>magic number</strong> tests are used to check for files with data in particular fixed formats. To determine the format of a file in this manner, either a magic number identifier exists at the beginning of the file, or a specific identifier can be determined at a specific offset within the file. The file <strong>/usr/share/file/magic</strong> specifies what magic numbers are to be tested for, what message to print if a particular magic number is found, and additional information to extract from the file.</p>
<p>Here is an example with a directory which contains a variety of file types. The output lists the filename along with its type.</p>
<pre>
$ file *
</pre>
<pre>
data:        data
directory:   directory
emptyfile:   empty
program:     ELF 64-bit LSB executable, x86-64, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), stripped
script.sh:   Bourne-Again shell script text executable
source.c:    ASCII C program text
symlink:     symbolic link to `program'
tarball.tar: POSIX tar archive (GNU)
tarball.tbz: bzip2 compressed data, block size = 900k
tarball.tgz: gzip compressed data, from Unix
text.txt:    ASCII text
</pre>
<p>This works equally well when the file names do not have have an extension, which is a very common case with Linux.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.wiredrevolution.com/commands/determine-file-type-with-the-file-command/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using tar to archive files</title>
		<link>http://www.wiredrevolution.com/commands/using-tar-to-archive-files</link>
		<comments>http://www.wiredrevolution.com/commands/using-tar-to-archive-files#comments</comments>
		<pubDate>Tue, 07 Oct 2008 13:33:17 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[commands]]></category>
		<category><![CDATA[archive]]></category>
		<category><![CDATA[bzip2]]></category>
		<category><![CDATA[gzip]]></category>
		<category><![CDATA[tar]]></category>
		<category><![CDATA[tarball]]></category>

		<guid isPermaLink="false">http://www.wiredrevolution.com/?p=234</guid>
		<description><![CDATA[<img src="http://www.wiredrevolution.com/wp-content/uploads/commands_icon.png" width="80" height="69" alt="" title="commands" /><br/>TAR is the GNU Tape ARchive utility. It is used to pack the contents of multiple files or directories in an archive file called a tarball. Tar can preserve directory organization including file ownership, permissions, links, as well as directory structure. To save space you can optionally enable compression with gzip, bzip2, or another external [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<img src="http://www.wiredrevolution.com/wp-content/uploads/commands_icon.png" width="80" height="69" alt="" title="commands" /><br/><p>TAR is the GNU Tape ARchive utility. It is used to pack the contents of multiple files or directories in an archive file called a <strong>tarball</strong>. Tar can preserve directory organization including file ownership, permissions, links, as well as directory structure. To save space you can optionally enable compression with <strong>gzip</strong>, <strong>bzip2</strong>, or another external program.</p>
<p>For these examples I&#8217;m going to be using this sample directory which contains a few files.</p>
<pre>
/mydir
/mydir/script.sh
/mydir/picture.jpg
/mydir/document.txt
</pre>
<p>Lets create a tarball from this directory. Run the following command.</p>
<pre>
$ tar -cvf mydir.tar mydir
</pre>
<p>Lets go over these options.</p>
<p><strong>-c</strong> create tarball<br />
<strong>-v</strong> verbose<br />
<strong>-f</strong> output file </p>
<p>To extract this tarball.</p>
<pre>
$ tar -xvf mydir.tar
</pre>
<p>The new option &#8216;<strong>-x</strong>&#8216; instructs tar to extract the archive.</p>
<p>Add compression with <strong>gzip</strong> when creating the archive by including the <strong>-z</strong> option.</p>
<pre>
$ tar -cvzf mydir.tgz mydir
</pre>
<p>Extracting the archive is similar. Make sure to include the gzip option as well.</p>
<pre>
$ tar -xvzf mydir.tgz
</pre>
<p>You can also use the <strong>bzip2</strong> utility to compress the archive, use the <strong>-j</strong> option.</p>
<pre>
$ tar -cvjf mydir.tbz mydir
</pre>
<p>And extract it.</p>
<pre>
$ tar -xvjf mydir.tbz
</pre>
<p>To preserve permissions use &#8216;<strong>-p</strong>&#8216; when creating as well as extracting.</p>
<pre>
$ tar -cvzpf mydir.tgz mydir
</pre>
<pre>
$ tar -xvzpf mydir.tgz
</pre>
<p>You may have noticed the file extensions used on the archives are different. Here is a quick rundown on the naming conventions.  Understanding the extensions allows you to quickly figure out how to extract it.</p>
<p>*.tar (uncompressed tar archive)<br />
*.tgz or *.tar.gz (gzip compressed tar archive)<br />
*.tbz or *.tar.bz2 (bzip2 compressed tar archive)</p>
<p>You want to avoid including files in the current working directory when creating a tarball.  When extracted these files will be dumped into the user&#8217;s current working directory instead of its own subdirectory, potentially overwriting files and creating a big mess.</p>
<p>Another helpful option to use is &#8216;<strong>-C</strong> <directory>&#8216;.  This will extract a tarball in a specific directory.</p>
<pre>
$ tar -xvzf mydir.tgz -C /tmp/testdir
</pre>
<p>A good way to check for any problems with extraction or to see exactly a tarball contains is to execute tar with the <strong>-t</strong> option. This will list the contents of a tarball and show the location they will be extracted.</p>
<pre>
$ tar -tf mydir.tgz
</pre>
<pre>
mydir/
mydir/script.sh
mydir/picture.jpg
mydir/document.txt
</pre>
<p>This will also help you avoid situations where a tarball might use an absolute path (path starting at root &#8216;/&#8217;) when extracting instead of a relative path (path that is relative to your current directory) like the previous examples.  This is not necessarily a bad thing, but it can be dangerous if you don&#8217;t realize this before extracting, since an absolute path can install to anywhere on your system. </p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.wiredrevolution.com/commands/using-tar-to-archive-files/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>View program output with watch</title>
		<link>http://www.wiredrevolution.com/commands/view-program-output-with-watch</link>
		<comments>http://www.wiredrevolution.com/commands/view-program-output-with-watch#comments</comments>
		<pubDate>Mon, 06 Oct 2008 12:35:31 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[commands]]></category>
		<category><![CDATA[watch]]></category>

		<guid isPermaLink="false">http://www.wiredrevolution.com/?p=227</guid>
		<description><![CDATA[<img src="http://www.wiredrevolution.com/wp-content/uploads/commands_icon.png" width="80" height="69" alt="" title="commands" /><br/>Watch runs a program at regular interval and continuously displays the output. This allows you keep track of the changes that are occurring in the program over time.  
Run watch in the following way.

watch [options] command

By default watch updates the command output every 2 seconds.  To change this interval us the &#8216;-n seconds&#8216; [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<img src="http://www.wiredrevolution.com/wp-content/uploads/commands_icon.png" width="80" height="69" alt="" title="commands" /><br/><p>Watch runs a program at regular interval and continuously displays the output. This allows you keep track of the changes that are occurring in the program over time.  </p>
<p>Run watch in the following way.</p>
<pre>
watch [options] <em>command</em>
</pre>
<p>By default watch updates the command output every 2 seconds.  To change this interval us the &#8216;<strong>-n seconds</strong>&#8216; option.</p>
<p>This will keep an eye on the changes occurring in your home directory. This will update the command output every second.</p>
<pre>
$ watch -n 1 ls -l ~/
</pre>
<p>If you use the &#8216;<strong>-d</strong>&#8216; option, watch will highlight the differences between the current and previous update. Adding  &#8216;<strong>-d=cumulative</strong>&#8216; will make the highlights permanent, allowing you to see what has changed throughout the entire run.</p>
<pre>
$ watch -d=cumulative ls -l ~/
</pre>
<p>String longer commands together by enclosing them in single quotes.</p>
<pre>
$ watch 'cat logfile | grep somestring'
</pre>
<p>Watch will continue to run until you exit the program by pressing <strong>Ctrl-C</strong>. </p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.wiredrevolution.com/commands/view-program-output-with-watch/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Submit commands as root with sudo</title>
		<link>http://www.wiredrevolution.com/commands/submit-commands-as-root-with-sudo</link>
		<comments>http://www.wiredrevolution.com/commands/submit-commands-as-root-with-sudo#comments</comments>
		<pubDate>Wed, 01 Oct 2008 13:31:05 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[commands]]></category>
		<category><![CDATA[NOPASSWD]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[sudo]]></category>
		<category><![CDATA[sudoers]]></category>
		<category><![CDATA[visudo]]></category>

		<guid isPermaLink="false">http://www.wiredrevolution.com/?p=167</guid>
		<description><![CDATA[<img src="http://www.wiredrevolution.com/wp-content/uploads/commands_icon.png" width="80" height="69" alt="" title="commands" /><br/>Among the most valuable tools at a Linux administrators disposal is sudo.  It lets ordinary users temporarily submit commands as root or another user.
To use use this command simply put sudo before any command you want to run with root permissions.

sudo command

To submit commands as another user use the &#8216;-u&#8216; option and the username. [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<img src="http://www.wiredrevolution.com/wp-content/uploads/commands_icon.png" width="80" height="69" alt="" title="commands" /><br/><p>Among the most valuable tools at a Linux administrators disposal is sudo.  It lets ordinary users temporarily submit commands as root or another user.</p>
<p>To use use this command simply put sudo before any command you want to run with root permissions.</p>
<pre>
sudo <em>command</em>
</pre>
<p>To submit commands as another user use the &#8216;<strong>-u</strong>&#8216; option and the username. This will submit a command as the user ryan.</p>
<pre>
sudo -u ryan <em>command</em>
</pre>
<p>The sudo configuration file is located at <strong>/etc/sudoers</strong>.</p>
<p>Although /etc/sudoers file is a regular text which root can edit manually, it is recommended that you only edit it using <strong>visudo</strong>. The visudo editor locks the sudoers file against multiple simultaneous edits, provides basic sanity checks, and checks for errors.</p>
<p>The /etc/sudoers file has the general format:</p>
<pre>
user hostlist = (userlist) commandlist
</pre>
<p>This is a basic configuration and will allow the user ryan to run any command, on any host, as any user.</p>
<pre>
# User privilege specification
root    ALL=(ALL) ALL
ryan    ALL=(ALL) ALL
</pre>
<p>Here is a more complex example.</p>
<pre>
ryan     tuxbox=(bob, bill)   /bin/kill
</pre>
<p>This will give ryan access to run &#8220;kill&#8221; as the users bob and bill using &#8220;sudo -u&#8221; on the host &#8220;tuxbox&#8221;.</p>
<p>When using the above configurations you will be prompted for ryan&#8217;s password before sudo will execute your command. After the pasword is accepted, you will have a 5 minute window to submit other commands without further password requests.</p>
<p>Submitting a password has its security benefits, but if you are ok without it, there is a way around this inconvenience. If you don&#8217;t want to enter a password add the <strong>NOPASSWD</strong> tag to the configuration file like this.</p>
<pre>
# User privilege specification
root    ALL=(ALL) ALL
ryan    ALL=(ALL) NOPASSWD: ALL
</pre>
<p>If there are configuration lines that contradict one another sudo will give priority to the line closest to the bottom of the file. So if you make changes and they don&#8217;t seem to take effect, check that this is not the case.</p>
<p>All calls to sudo are logged in <strong>/var/log/messages</strong> so you have the ability to keep track of who did what on the system.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.wiredrevolution.com/commands/submit-commands-as-root-with-sudo/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to take a screenshot in Linux using import</title>
		<link>http://www.wiredrevolution.com/commands/how-to-take-a-screenshot-in-linux-using-import</link>
		<comments>http://www.wiredrevolution.com/commands/how-to-take-a-screenshot-in-linux-using-import#comments</comments>
		<pubDate>Sun, 28 Sep 2008 15:52:56 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[commands]]></category>
		<category><![CDATA[gimp]]></category>
		<category><![CDATA[imagemagik]]></category>
		<category><![CDATA[import]]></category>
		<category><![CDATA[screenshot]]></category>

		<guid isPermaLink="false">http://www.wiredrevolution.com/?p=135</guid>
		<description><![CDATA[<img src="http://www.wiredrevolution.com/wp-content/uploads/commands_icon.png" width="80" height="69" alt="" title="commands" /><br/>There are many ways to take screenshot in Linux.  If you have Gnome or KDE you can simply press your &#8216;print screen&#8217; button and you are done.
If you don&#8217;t run either one of these desktops you can always use the screenshot functionality built into GNU Image Manipulation Program aka GIMP. Open up GIMP and [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<img src="http://www.wiredrevolution.com/wp-content/uploads/commands_icon.png" width="80" height="69" alt="" title="commands" /><br/><p>There are many ways to take screenshot in Linux.  If you have Gnome or KDE you can simply press your &#8216;print screen&#8217; button and you are done.</p>
<p>If you don&#8217;t run either one of these desktops you can always use the screenshot functionality built into GNU Image Manipulation Program aka GIMP. Open up GIMP and navigate to <strong>File -&gt; Create -&gt; Screenshot</strong>.</p>
<p>The third method and my favorite is to do it from the command line.</p>
<p>To do this you need to use the import command which is part of <strong>ImageMagik</strong> package.  You will need to make sure that this is installed before you continue.</p>
<p>The import command saves any visible window on an X server and outputs it as an image file. You can capture a single window, the entire screen, or any rectangular portion of the screen.</p>
<p>The format for import looks like this.</p>
<pre>
import [options] input-file
</pre>
<p>To create a screenshot of the entire root window and output in PNG format run this command.</p>
<pre>
$ import -window root screenimage.png
</pre>
<p>You can change the format of the image by simply changing the file extension.  For example this command outputs the same root window but in JPEG format.</p>
<pre>
$ import -window root screenimage.jpg
</pre>
<p>Another great feature is that you can get a screenshot of a single window.  Run this command.</p>
<pre>
$ import screenimage.jpg
</pre>
<p>After you enter this command your mouse curser will turn from a pointer into a crosshair. Now go and click on any window on your desktop and the screenshot that is created will be of only that window.  </p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.wiredrevolution.com/commands/how-to-take-a-screenshot-in-linux-using-import/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Securely copy remote files with scp</title>
		<link>http://www.wiredrevolution.com/commands/securely-copy-remote-files-with-scp</link>
		<comments>http://www.wiredrevolution.com/commands/securely-copy-remote-files-with-scp#comments</comments>
		<pubDate>Sat, 27 Sep 2008 17:27:30 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[commands]]></category>
		<category><![CDATA[scp]]></category>
		<category><![CDATA[SSH]]></category>

		<guid isPermaLink="false">http://www.wiredrevolution.com/?p=114</guid>
		<description><![CDATA[<img src="http://www.wiredrevolution.com/wp-content/uploads/commands_icon.png" width="80" height="69" alt="" title="commands" /><br/>scp allows you to securely copy files locally or remotely across a network. It uses SSH for data transfer and uses the same authentication. If you do not have public key authentication enabled you will be prompted for a password.
This basic format for scp is this.

scp [options] [[user@]src_host1:]file1 [[user@]dest_host2:]file2

Assuming the remotehost has a username which [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<img src="http://www.wiredrevolution.com/wp-content/uploads/commands_icon.png" width="80" height="69" alt="" title="commands" /><br/><p><strong>scp</strong> allows you to securely copy files locally or remotely across a network. It uses <strong>SSH</strong> for data transfer and uses the same authentication. If you do not have public key authentication enabled you will be prompted for a password.</p>
<p>This basic format for scp is this.</p>
<pre>
scp [options] [[user@]src_host1:]file1 [[user@]dest_host2:]file2
</pre>
<p>Assuming the remotehost has a username which matches username on the local host, this command will copy a a local file into the /tmp directory on remotehost. Notice that the colon separates the host from the location.</p>
<pre>
$ scp file.txt remotehost:/tmp/
</pre>
<p>You will be presented with the real-time statistics about the file transfer.</p>
<pre>
$ scp file.txt remotehost:/tmp/
</pre>
<pre>
file.txt                                      100%   22KB  21.9KB/s   00:00
</pre>
<p>This command is similar but the period instructs the file to be placed in the users home directory.</p>
<pre>
$ scp file.txt remotehost:.
</pre>
<p>You can specify another user and login using their username.  This will copy the file to ryan&#8217;s home directory.</p>
<pre>
$ scp file.txt ryan@remotehost:.
</pre>
<p>Alternatively you can copy a remote file to your local host. The period in the destination path refers to the current working directory in this case.</p>
<pre>
$ scp ryan@remotehost:file.txt .
</pre>
<p>Likewise, you can copy to any other local path you have access, such as the /tmp directory.</p>
<pre>
$ scp ryan@remotehost:file.txt /tmp/
</pre>
<p>Copying directories is similar except that the &#8216;-r&#8217; option is required. This command will copy a directory from the current working directory to the users home directory on remotehost.</p>
<pre>
$ scp -r mydir/ remotehost:.
</pre>
<p>You can even copy from one remote host to another.</p>
<pre>
$ scp remotehost1:file.txt remotehost2:file.txt
</pre>
<p>Use the -p option to preserve modification times, access times, and modes from the original file.</p>
<pre>
$ scp -p remotehost1:/tmp/file.txt remotehost2:/tmp/file.txt
</pre>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.wiredrevolution.com/commands/securely-copy-remote-files-with-scp/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>View real-time system statistics with top</title>
		<link>http://www.wiredrevolution.com/commands/view-real-time-system-statistics-with-top</link>
		<comments>http://www.wiredrevolution.com/commands/view-real-time-system-statistics-with-top#comments</comments>
		<pubDate>Fri, 26 Sep 2008 13:18:43 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[commands]]></category>
		<category><![CDATA[top]]></category>

		<guid isPermaLink="false">http://www.wiredrevolution.com/?p=85</guid>
		<description><![CDATA[<img src="http://www.wiredrevolution.com/wp-content/uploads/commands_icon.png" width="80" height="69" alt="" title="commands" /><br/>The top command is a great way to keep track of processes executing on a system in real-time.
Launch top by entering this on the command line.

$ top

Here is an example of what you will see.

top - 09:13:11 up  1:29,  2 users,  load average: 0.20, 0.16, 0.10
Tasks:  85 total,   1 [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<img src="http://www.wiredrevolution.com/wp-content/uploads/commands_icon.png" width="80" height="69" alt="" title="commands" /><br/><p>The top command is a great way to keep track of processes executing on a system in real-time.</p>
<p>Launch top by entering this on the command line.</p>
<pre>
$ top
</pre>
<p>Here is an example of what you will see.</p>
<pre>
top - 09:13:11 up  1:29,  2 users,  load average: 0.20, 0.16, 0.10
Tasks:  85 total,   1 running,  84 sleeping,   0 stopped,   0 zombie
Cpu(s):  2.5%us,  1.0%sy,  0.0%ni, 96.0%id,  0.0%wa,  0.4%hi,  0.1%si,  0.0%st
Mem:   4050364k total,   459920k used,  3590444k free,    17028k buffers
Swap:  1956612k total,        0k used,  1956612k free,   174940k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 5521 root      20   0  897m  49m 8924 S    7  1.3   8:18.19 X
 5574 ryan      20   0  139m  21m  10m S    2  0.6   0:48.17 compiz
 5932 ryan      20   0  142m  18m 9876 S    1  0.5   0:00.28 Terminal
 5589 ryan      20   0  174m  86m  19m S    0  2.2   1:37.46 firefox-bin
    1 root      20   0  3712  580  492 S    0  0.0   0:01.14 init
    2 root      15  -5     0    0    0 S    0  0.0   0:00.00 kthreadd
    3 root      RT  -5     0    0    0 S    0  0.0   0:00.00 migration/0
    4 root      15  -5     0    0    0 S    0  0.0   0:00.04 ksoftirqd/0
    5 root      RT  -5     0    0    0 S    0  0.0   0:00.00 migration/1
    6 root      15  -5     0    0    0 S    0  0.0   0:00.02 ksoftirqd/1
</pre>
<p>The &#8216;<strong>-d delay</strong>&#8216; option will change the amount of time between updates.<br />
This will set the delay for half a second.</p>
<pre>
$ top -d 0.5
</pre>
<p>The &#8216;<strong>-n iterations</strong>&#8216; option allows you to define the number of iterations it displays before it exits.  It is handy when you want to see a single snapshot of the system. To do this, enter this command. </p>
<pre>
$ top -n 1
</pre>
<p>The &#8216;<strong>-u user</strong>&#8216; option allows you to view the processes of a single user</p>
<pre>
$ top -u ryan
</pre>
<p>The <strong>&#8216;-p PID</strong>&#8216;  option shows you a specific process or group of processes by listing their process IDs. </p>
<pre>
$ top -p 1001
</pre>
<pre>
$ top -p 1001,1002,1003
</pre>
<p>By default top is launched in interactive mode. In this mode you can submit commands that will change the behavior of the program.</p>
<p>Pressing &#8216;<strong>f</strong>&#8216; will allow you to select what fields to display.<br />
You will see a screen similar to this.</p>
<pre>
Current Fields:  AEHIOQTWKNMbcdfgjplrsuvyzX  for window 1:Def
Toggle fields via field letter, type any other key to return 

* A: PID        = Process Id
* E: USER       = User Name
* H: PR         = Priority
* I: NI         = Nice value
* O: VIRT       = Virtual Image (kb)
* Q: RES        = Resident size (kb)
* T: SHR        = Shared Mem size (kb)
* W: S          = Process Status
* K: %CPU       = CPU usage
* N: %MEM       = Memory usage (RES)
* M: TIME+      = CPU Time, hundredths
  b: PPID       = Parent Process Pid
  c: RUSER      = Real user name
  d: UID        = User Id
  f: GROUP      = Group Name
  g: TTY        = Controlling Tty
  j: P          = Last used cpu (SMP)
  p: SWAP       = Swapped size (kb)
  l: TIME       = CPU Time
  r: CODE       = Code size (kb)
  s: DATA       = Data+Stack size (kb)
  u: nFLT       = Page Fault count
  v: nDRT       = Dirty Pages count
  y: WCHAN      = Sleeping in Function
  z: Flags      = Task Flags <sched.h>
* X: COMMAND    = Command name/line
</pre>
<p>Similarly, &#8216;<strong>o</strong>&#8216; will allow you to change the order of the fields that are currently displayed.</p>
<p>If you have multiple CPUs or processor cores the pressing &#8216;<strong>1</strong>&#8216; will give you more individual information on each one.</p>
<pre>
top - 11:58:37 up  1:34,  2 users,  load average: 0.17, 0.13, 0.09
Tasks:  87 total,   2 running,  85 sleeping,   0 stopped,   0 zombie
Cpu0  :  5.7%us,  1.5%sy,  0.0%ni, 92.1%id,  0.3%wa,  0.2%hi,  0.1%si,  0.0%st
Cpu1  :  5.4%us,  1.5%sy,  0.0%ni, 92.3%id,  0.4%wa,  0.2%hi,  0.1%si,  0.0%st
Mem:   4050364k total,   510172k used,  3540192k free,    17264k buffers
Swap:  1956612k total,        0k used,  1956612k free,   245704k cached
</pre>
<p>You can exit by pressing <strong>Ctrl-C</strong>.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.wiredrevolution.com/commands/view-real-time-system-statistics-with-top/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
