<?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>h4x3d.com &#187; sh</title>
	<atom:link href="http://h4x3d.com/tag/sh/feed/" rel="self" type="application/rss+xml" />
	<link>http://h4x3d.com</link>
	<description>online portfolio of Julian Klewes</description>
	<lastBuildDate>Thu, 24 May 2012 18:50:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Simple Linux Commands</title>
		<link>http://h4x3d.com/simple-linux-commands/</link>
		<comments>http://h4x3d.com/simple-linux-commands/#comments</comments>
		<pubDate>Wed, 10 Aug 2005 18:04:43 +0000</pubDate>
		<dc:creator>jez</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[commands]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[sh]]></category>

		<guid isPermaLink="false">http://www.h4x3d.com/v9.1/?p=7</guid>
		<description><![CDATA[Listing Directory Contents To list all directories and files within a current directory, type: ls To list a detailed list of all directories and files sorted by creation date, type: ls -lrt Locations of Files and Directories To work with a file or directory, it is important to tell Linux where to find it. There [...]]]></description>
			<content:encoded><![CDATA[<p>Listing Directory Contents</p>
<p>To list all directories and files within a current directory, type:</p>
<p>ls</p>
<p>To list a detailed list of all directories and files sorted by creation date, type:</p>
<p>ls -lrt</p>
<p>Locations of Files and Directories</p>
<p>To work with a file or directory, it is important to tell Linux where to find it. There are several ways to tell Linux where to look:</p>
<p>./ = the current directory<br />
../ = the parent directory of ./ (one directory up)<br />
/ = the root directory (top directory)</p>
<p>When no location is specified, Linux assumes we mean &#8220;./&#8221;. So we can copy &#8220;fileX&#8221; from the current directory to its parent directory using either:<br />
cp /whole/path/from/root/directory/fileX ../</p>
<p>or:<br />
cp ./fileX ../</p>
<p>or:<br />
cp fileX ../</p>
<p>Viewing Files</p>
<p>There are many ways to view a text file. For viewing and editing, see the section below on text editors. One way for simple viewing is to type:</p>
<p>less</p>
<p>This displays as much of the file as can fit onto the screen. To scroll up and down within the document, use the arrow keys. Hitting the space bar will bring a new screen-full of information.</p>
<p>To search forward in the file for a given pattern, press:</p>
<p>/pattern</p>
<p>To exit less, press:</p>
<p>q</p>
<p>Creating and Editing Files</p>
<p>There are several text editors that create plain text files. We have emacs and vi available from the terminals. Unless you are already familiar with vi, we strongly recommend that you use emacs. We strongly recommend you study the emacs tutorial, which you can easily start in any emacs session. To open and edit a file in emacs, simply type</p>
<p>emacs myfile</p>
<p>To create and edit a new file, type</p>
<p>emacs newfile</p>
<p>To edit a file in emacs and still be able to use the command prompt, type</p>
<p>emacs myfile &amp;</p>
<p>If you forgot to type the &#8220;&amp;&#8221; and you want to return to the command prompt mode, type</p>
<p>Control-Z</p>
<p>This command will suspend the emacs application, but will not kill it. Then type:</p>
<p>bg</p>
<p>to have emacs working in the background.</p>
<p>***User home directories are set at a maximum storage space of 3 gigabytes. Should you exceed your storage space, you will be warned that you are at your maximum storage space. Contact the Workshop computer staff before the grace period on this expires and anything of yours is possibly lost.***</p>
<p>Moving Files</p>
<p>Because of the way files are accessed in UNIX/Linux, moving a file is the same as renaming it. The command mv works like:<br />
mv file1 file2</p>
<p>For example:</p>
<p>mv fileformats.html index.html</p>
<p>takes fileformats.html and renames it index.html.<br />
Files can be moved from one location to another:</p>
<p>mv location/file1 location/file2</p>
<p>For example:</p>
<p>mv /home/mwaring/to-do-list /home/mwaring/Tasks/</p>
<p>This command moves the file to-do-list from /home/mwaring/ to /home/mwaring/Tasks/. To move a file and also rename it, specify a name after the second location. For example:<br />
mv /home/mwaring/more-stuff /home/mwaring/Tasks/additional-tasks</p>
<p>Copying Files</p>
<p>To copy a file using a terminal, use<br />
cp</p>
<p>For example:</p>
<p>cp template.html course-schedule.html</p>
<p>This makes a new file that contains the same information as the first file with the name indicated. In the example above, cp takes the contents of template.html and makes a file called course-schedule.html that contains all the information in template.html.</p>
<p>cp can also be used to copy a file from one directory to another. For example:</p>
<p>cp /home/tmp/mbl.color.logo.jpg /home/mwaring/images/MBL.jpg</p>
<p>This command will take MBL.color.logo.jpg in /home/tmp and copy it to /home/mwaring/images. It names the copy MBL.jpg. If a name is not specified for the file, a copy with the same name as the original is made. For example:</p>
<p>cp /home/tmp/mbl.color.logo.jpg /home/mwaring/images</p>
<p>To copy an entire directory, use the -R flag.</p>
<p>cp -R dir-to-copy/ new-dir/</p>
<p>For example:</p>
<p>cp -R /home/tmp/images/ /home/mwaring/temp-images</p>
<p>copies the directory in /home/tmp called images into the temp-images directory in /home/mwaring. Note: on some computers, cp -R does not copy dot-files (files that start with &#8216;.&#8217;, for example .bashrc).</p>
<p>You may run into trouble copying files from or to directories which you do not have permission to read or execute.</p>
<p>Removing Files</p>
<p>rm is the command to remove a file. There are flags (options) that can be used with rm. To delete a file, type:</p>
<p>rm filename</p>
<p>For example, to delete a file called coi.nex, type:</p>
<p>rm coi.nex</p>
<p>A prompt will ask if you really want to delete it. If so, type:</p>
<p>y</p>
<p>To delete a file from a different directory, supply rm with the pathname. For example:</p>
<p>rm /home/mwaring/coi.nex</p>
<p>Creating Directories</p>
<p>To create a new directory, type:</p>
<p>mkdir directory1</p>
<p>This will create a directory called directory1.</p>
<p>Changing Directories</p>
<p>To view the pathway of the current directory, type:</p>
<p>pwd</p>
<p>This will show output such as</p>
<p>/home/mwaring/directory1</p>
<p>To go &#8220;up&#8221; one directory (in this example, to go from directory1 to mwaring), type:</p>
<p>cd ..</p>
<p>To go &#8220;down&#8221; one directory (in this example, to go from mwaring to directory1), type:</p>
<p>cd directory1</p>
<p>To go &#8220;back&#8221; to your home directory, type:</p>
<p>cd</p>
<p>Deleting Directories</p>
<p>To delete a directory, type:</p>
<p>rm -r directory1</p>
<p>This will remove the directory and all the files in it so use this command carefully.</p>
<p>Viewing PDF files</p>
<p>PDF files can be accessed by either downloading and saving or reading files directly. To view files that have been downloaded, go to the terminal window and type:</p>
<p>acroread file1</p>
<p>This will open the pdf file in acrobat reader.</p>
<p>Getting Help</p>
<p>While the workshop is in session, one of your best sources of help are the teaching assistants and support staff.</p>
<p>This page will still be accessible after the course, but contains help on only a few basic UNIX commands. Some material may not apply to your home systems. On most systems, typing</p>
<p>man command</p>
<p>invokes information about commands.</p>
<p>For example, to learn how cp works, type:</p>
<p>man cp</p>
<p>To exit the man page, hit:</p>
<p>q</p>
<p>Note: man pages are often a bit obtuse, but are worth reading nevertheless.</p>
<p>ssh</p>
<p>ssh is a program to connect to another computer. For Linux and Mac OS X, there are two ways of using ssh from a terminal:</p>
<p>ssh user@computer</p>
<p>or</p>
<p>ssh computer -l user</p>
<p>For example:</p>
<p>ssh mwaring@gcg.workshop.priv</p>
<p>or</p>
<p>ssh gcg.workshop.priv -l mwaring</p>
<p>You will then be asked for your password.</p>
<p>If you are using a notebook computer and it does not already have an ssh client program, you can get one for free. For MacOS 9, visit Nifty Telnet-SSH and download the client. Windows users can download Putty, a free ssh client.</p>
<p>Note: Your home directory (and all of /home) is available for you on every machine in the lab.</p>
<p>Copying Files between Machines (File Transfer)</p>
<p>Some of you may be familiar with ftp (File Transfer Protocol). We do not have ftp here because it is a relatively insecure method of transferring files between computers. To transfer files between machines, you need to use:</p>
<p>scp</p>
<p>This command works very similarly to cp, except that the files you are copying reside on different machines.</p>
<p>To copy a file from a remote computer to the computer you are working at, you type:</p>
<p>scp user@remote-computer:/remote/path/remote-file /local/path/local-file</p>
<p>You will then be prompted for the user&#8217;s password on the remote computer. After you enter it, the file will be copied. For example:</p>
<p>scp molly@bigbox.university.edu:/home/molly/Info/info /home/mwaring/facts</p>
<p>If I am working on nixon (for example), this command will copy the file called info that lives on bigbox.university.edu at /home/molly/Info to /home/mwaring on nixon and will name it &#8216;facts&#8217;. For those of you familiar with ftp, this is like &#8216;get remote-file local-file&#8217;. Note: if you do not specify a local name, scp will name the file the same name as the remote file.</p>
<p>To copy a local file onto a remote computer, you type:</p>
<p>scp /local/path/local-file user@remote-computer:/remote/path/remote-file</p>
<p>For those of you familiar with ftp, this is like &#8216;put local-file remote-file&#8217;.Note: As with cp, you need to have read/execute permissions on the two files. Also, you should only specify one computer name (either the local host or the remote host).</p>
<p>As with the cp command, you can specify the -r flag to recursively copy entire directories.</p>
<p>Note: This does not work with Windows machines. scp works only between UNIX/Linux machines.</p>
]]></content:encoded>
			<wfw:commentRss>http://h4x3d.com/simple-linux-commands/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

