{"id":774,"date":"2012-08-24T13:42:25","date_gmt":"2012-08-24T13:42:25","guid":{"rendered":"http:\/\/naich.net\/wordpress\/?p=774"},"modified":"2012-09-20T11:05:24","modified_gmt":"2012-09-20T11:05:24","slug":"teapot-wibble","status":"publish","type":"post","link":"https:\/\/naich.net\/wordpress\/index.php\/teapot-wibble\/","title":{"rendered":"Miscallaneous Wibble"},"content":{"rendered":"<p>This post is part of a short series of tutorials for people who are new to using their Raspberry Pi.\u00c2\u00a0 It will make more sense if you <a title=\"Yummy Pi \u00e2\u20ac\u201c what to do with a Raspberry Pi\" href=\"http:\/\/naich.net\/wordpress\/?p=435\">start at the beginning<\/a>.<\/p>\n<p><a title=\"A streaming pile of Pi\" href=\"http:\/\/naich.net\/wordpress\/?p=641\">Continued from here.<\/a><\/p>\n<p><a title=\"Yummy Pi\" href=\"http:\/\/naich.net\/wordpress\/?p=435\">First page here<\/a><\/p>\n<h3>12.\u00c2\u00a0 Some other useful bits and bobs<\/h3>\n<p>Firstly, let me say that Linux is a huge subject and I&#8217;m only scratching the surface here.\u00c2\u00a0 Also, my knowledge on the subject is not that great; I know enough to get by and Google for everything else.\u00c2\u00a0 Secondly, all this huge operating system is contained within the 2GB SD\u00c2\u00a0 card plugged into your Pi.\u00c2\u00a0 That&#8217;s about \u00c2\u00a330 of hardware to create what used to be called a mainframe computer, and if you aren&#8217;t impressed by that, you haven&#8217;t understood how much your Pi can do.\u00c2\u00a0 Here are some bits and bobs that you might find useful as you learn more.<\/p>\n<h4>12.1\u00c2\u00a0 Pipe to your grep<\/h4>\n<p>Pipes were briefly mentioned earlier, as a way to stop text whooshing off the top of your screen by appending <strong><tt>|more<\/tt><\/strong> to the end of a command.\u00c2\u00a0 Here is a brief, incomplete and misleading explanation of how they work.<\/p>\n<p>It&#8217;s in the nature of computers that programs take something in, do something and then put something out.\u00c2\u00a0 A program with no inputs or outputs doesn&#8217;t do much, after all.\u00c2\u00a0 You might think that command line programs take their data in from the keyboard and put it out to the screen but they actually talk to the <a href=\"http:\/\/en.wikipedia.org\/wiki\/Standard_streams\">streams, stdin and stdout<\/a> &#8211; which you can think of as being like a plug and socket, one at each end of the program, through which data is poured.\u00c2\u00a0 It is the <a href=\"http:\/\/en.wikipedia.org\/wiki\/Shell_%28computing%29\">shell<\/a> (Raspbian uses &#8220;<a href=\"http:\/\/en.wikipedia.org\/wiki\/Bash_%28Unix_shell%29\">bash<\/a>&#8221; by default) that acts as an interface between you and the computer, linking the keyboard to the stdin stream and the screen to the stdout stream.\u00c2\u00a0 Thanks to the standardised way data is pumped in and out of programs, you can join them together so the output of one program becomes the input of another.\u00c2\u00a0 This is done with a &#8220;pipe&#8221; &#8211; | which is simply placed between the programs so that the data flows from left to right.\u00c2\u00a0 Examples will probably make more sense than words.<\/p>\n<p>&#8220;<a href=\"http:\/\/linux.die.net\/man\/1\/grep\">grep<\/a>&#8221; is a program which searches for words through whatever text is put into it.\u00c2\u00a0 There are many ways to use it; like searching through files for a word &#8211; let&#8217;s find lines containing the word &#8220;transmission&#8221; in the log file for dpkg (which is used by Apt):<\/p>\n<blockquote>\n<pre>naich@raspberrypi ~ $ <strong>grep transmission \/var\/log\/dpkg.log<\/strong>\r\n2012-08-06 12:39:49 install transmission-common:all &lt;none&gt; 2.52-3\r\n2012-08-06 12:39:49 status half-installed transmission-common:all 2.52-3\r\n2012-08-06 12:39:49 status half-installed transmission-common:all 2.52-3\r\n... and so on ...<\/pre>\n<\/blockquote>\n<p>grep can also take its input from stdin (it automatically does this if you leave the filename off the end of the command), with a pipe.\u00c2\u00a0 In this example, &#8220;<a href=\"http:\/\/linux.die.net\/man\/1\/cat\">cat<\/a> filename&#8221; prints the contents of the file &#8220;filename&#8221; which is then piped to grep which prints lines containing &#8220;transmission&#8221;:<\/p>\n<blockquote>\n<pre>naich@raspberrypi ~ $ <strong>cat \/var\/log\/dpkg.log | grep transmission<\/strong>\r\n2012-08-06 12:39:49 install transmission-common:all &lt;none&gt; 2.52-3\r\n2012-08-06 12:39:49 status half-installed transmission-common:all 2.52-3\r\n2012-08-06 12:39:49 status half-installed transmission-common:all 2.52-3\r\n... the same stuff as above ...<\/pre>\n<\/blockquote>\n<p>But it&#8217;s still whooshing off the screen, so let&#8217;s take the output of &#8220;grep&#8221; and pipe it to &#8220;more&#8221; (no filename after the &#8220;more&#8221; command makes it read from stdin), which paginates it:<\/p>\n<blockquote>\n<pre>naich@raspberrypi ~ $ <strong>cat \/var\/log\/dpkg.log | grep transmission | more<\/strong>\r\n2012-08-06 12:39:49 install transmission-common:all &lt;none&gt; 2.52-3\r\n2012-08-06 12:39:49 status half-installed transmission-common:all 2.52-3\r\n...\r\n2012-08-06 12:40:01 status unpacked transmission-daemon:armhf 2.52-3\r\n--More--<\/pre>\n<\/blockquote>\n<p>Or we could use &#8220;<a href=\"http:\/\/linux.die.net\/man\/1\/wc\">wc<\/a>&#8221; to count the number of times it appears.\u00c2\u00a0 As with &#8220;grep&#8221; and &#8220;more&#8221;, leaving off a filename makes wc read text from stdin rather than a file.\u00c2\u00a0 &#8220;wc -l&#8221; counts the number of lines stuffed into its stdin:<\/p>\n<blockquote>\n<pre>naich@raspberrypi ~ $ <strong>cat \/var\/log\/dpkg.log | grep transmission | wc -l<\/strong>\r\n31\r\nnaich@raspberrypi ~ $<\/pre>\n<\/blockquote>\n<p>All these programs have man page help, by the way.\u00c2\u00a0 grep is probably the most useful tool in the Linux toolbox so it&#8217;s worth finding out about it.\u00c2\u00a0 Also read up about <a href=\"http:\/\/tldp.org\/LDP\/abs\/html\/io-redirection.html\">redirection<\/a>, which is a related subject.<\/p>\n<h4>12.2\u00c2\u00a0 Processes, and how to kill them<\/h4>\n<p>All programs that run on the Pi (known as &#8220;processes&#8221;) &#8211; autonomous daemons, interactive programs and even the program that boots it, have two things &#8211; a unique ID number (process ID or &#8220;pid&#8221;) and a user who owns it (user ID or &#8220;uid&#8221;).\u00c2\u00a0 Well, obviously they have <em>more<\/em> than two things, but these two are the most important.<\/p>\n<p>The pid is a unique number between 1 and 32768.\u00c2\u00a0 Each process gets a pid when it starts which is one more than the previous one assigned, unless it&#8217;s already taken, in which case the next higher one is assigned.\u00c2\u00a0 The numbers wrap round to 2 (1 is always used by the &#8220;init&#8221; process) when they hit 32768.<\/p>\n<p>The process also has a user ID (uid), the same as one of the users on the system, as if the user had started the process himself.\u00c2\u00a0 The process inherits the identity of the user, writing files in his name for example, and has the same permissions to read, write and execute files as that user.\u00c2\u00a0 So a process running as &#8220;root&#8221;, with a uid of 0 can do anything.\u00c2\u00a0 Processes that don&#8217;t need to run as root tend to run as their own user, in order to sand box them into their own little world.\u00c2\u00a0 You can see this, for example with Transmission, which runs under the uid of 106 &#8211; debian-transmission.<\/p>\n<p>You can get a list of processes currently running on your Pi with the &#8220;<a href=\"http:\/\/linux.die.net\/man\/1\/ps\">ps<\/a>&#8221; command:<\/p>\n<blockquote>\n<pre>naich@raspberrypi ~ $ <strong>ps -ef<\/strong>\r\nUID\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 PID\u00c2\u00a0 PPID\u00c2\u00a0 C STIME TTY\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 TIME CMD\r\nroot\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 1\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 0\u00c2\u00a0 0 Aug20 ?\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 00:00:14 init [2]\r\nroot\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 2\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 0\u00c2\u00a0 0 Aug20 ?\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 00:00:00 [kthreadd]\r\nroot\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 3\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 2\u00c2\u00a0 0 Aug20 ?\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 00:00:09 [ksoftirqd\/0]\r\n... lots of processes ...\r\n106\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 2382\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 1\u00c2\u00a0 0 Aug21 ?\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 00:22:56 \/usr\/bin\/transmission-daemon --c\r\n107\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 3527\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 1\u00c2\u00a0 0 Aug23 ?\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 00:13:52 \/usr\/bin\/mediatomb -c \/etc\/media\r\nroot\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 3860\u00c2\u00a0 1949\u00c2\u00a0 0 11:35 ?\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 00:00:00 sshd: naich [priv]\r\nnaich\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 3867\u00c2\u00a0 3860\u00c2\u00a0 0 11:35 ?\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 00:00:00 sshd: naich@pts\/0\r\nnaich\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 3868\u00c2\u00a0 3867\u00c2\u00a0 0 11:35 pts\/0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 00:00:01 -bash\r\nnaich\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 3941\u00c2\u00a0 3868\u00c2\u00a0 0 12:27 pts\/0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 00:00:00 ps -ef\r\nnaich@raspberrypi ~ $<\/pre>\n<\/blockquote>\n<p>This shows the user ID (UID), process ID (PID) the process ID of the process which started it (PPID), the start time (STIME), the amount of CPU time it has taken up (TIME) and the command that started it (CMD).\u00c2\u00a0 Another, more interactive way to show processes is with the &#8220;top&#8221; command:<\/p>\n<blockquote>\n<pre>naich@raspberrypi ~ $ <strong>top<\/strong>\r\ntop - 12:41:13 up 3 days, 16:25,\u00c2\u00a0 1 user,\u00c2\u00a0 load average: 0.00, 0.01, 0.05\r\nTasks:\u00c2\u00a0 57 total,\u00c2\u00a0\u00c2\u00a0 1 running,\u00c2\u00a0 56 sleeping,\u00c2\u00a0\u00c2\u00a0 0 stopped,\u00c2\u00a0\u00c2\u00a0 0 zombie\r\n%Cpu(s):\u00c2\u00a0 1.3 us,\u00c2\u00a0 1.6 sy,\u00c2\u00a0 0.0 ni, 95.4 id,\u00c2\u00a0 0.0 wa,\u00c2\u00a0 0.0 hi,\u00c2\u00a0 1.6 si,\u00c2\u00a0 0.0 st\r\nKiB Mem:\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 220592 total,\u00c2\u00a0\u00c2\u00a0 209612 used,\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 10980 free,\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 7192 buffers\r\nKiB Swap:\u00c2\u00a0\u00c2\u00a0 102396 total,\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 568 used,\u00c2\u00a0\u00c2\u00a0 101828 free,\u00c2\u00a0\u00c2\u00a0 163588 cached\r\n\r\n\u00c2\u00a0 PID USER\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 PR\u00c2\u00a0 NI\u00c2\u00a0 VIRT\u00c2\u00a0 RES\u00c2\u00a0 SHR S\u00c2\u00a0 %CPU %MEM\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 TIME+\u00c2\u00a0 COMMAND\r\n\u00c2\u00a02382 debian-t\u00c2\u00a0 20\u00c2\u00a0\u00c2\u00a0 0 43732\u00c2\u00a0 11m\u00c2\u00a0 896 S\u00c2\u00a0\u00c2\u00a0 1.0\u00c2\u00a0 5.1\u00c2\u00a0 23:02.69 transmission-da\r\n\u00c2\u00a03945 naich\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 20\u00c2\u00a0\u00c2\u00a0 0\u00c2\u00a0 4616 1348 1028 R\u00c2\u00a0\u00c2\u00a0 1.0\u00c2\u00a0 0.6\u00c2\u00a0\u00c2\u00a0 0:00.22 top\r\n\u00c2\u00a03527 mediatom\u00c2\u00a0 20\u00c2\u00a0\u00c2\u00a0 0\u00c2\u00a0 152m 9.9m\u00c2\u00a0 800 S\u00c2\u00a0\u00c2\u00a0 0.3\u00c2\u00a0 4.6\u00c2\u00a0 13:53.06 mediatomb\r\n\u00c2\u00a03867 naich\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 20\u00c2\u00a0\u00c2\u00a0 0 10524 1768 1056 S\u00c2\u00a0\u00c2\u00a0 0.3\u00c2\u00a0 0.8\u00c2\u00a0\u00c2\u00a0 0:01.54 sshd\r\n... and so on ...<\/pre>\n<\/blockquote>\n<p>The &#8220;%CPU&#8221; and &#8220;%MEM&#8221; show the amount of CPU time and system memory each process is using at this moment and is useful in catching processes that are running out of control.\u00c2\u00a0 Press &#8220;H&#8221; to see the help page or &#8220;Q&#8221; to quit.\u00c2\u00a0 If you need to stop a process running and can&#8217;t find a way to do it nicely (with &#8220;service process stop&#8221;, for example), then you can kill it with <a href=\"http:\/\/linux.die.net\/man\/1\/kill\">kill<\/a>.\u00c2\u00a0 Let&#8217;s make a process and kill it.<\/p>\n<blockquote>\n<pre>naich@raspberrypi ~ $ <strong>sleep 600 &amp;<\/strong>\r\n[1] 3984\r\nnaich@raspberrypi ~ $ <strong>ps -fu naich<\/strong>\r\nUID\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 PID\u00c2\u00a0 PPID\u00c2\u00a0 C STIME TTY\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 TIME CMD\r\nnaich\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 3867\u00c2\u00a0 3860\u00c2\u00a0 0 11:35 ?\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 00:00:01 sshd: naich@pts\/0\r\nnaich\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 3868\u00c2\u00a0 3867\u00c2\u00a0 0 11:35 pts\/0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 00:00:01 -bash\r\nnaich\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 3984\u00c2\u00a0 3868\u00c2\u00a0 0 12:47 pts\/0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 00:00:00 sleep 600\r\nnaich\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 3986\u00c2\u00a0 3868\u00c2\u00a0 0 12:47 pts\/0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 00:00:00 ps -fu naich<\/pre>\n<\/blockquote>\n<p>&#8220;sleep&#8221; is a program that does nothing for the number of seconds you tell it.\u00c2\u00a0 The &#8220;&amp;&#8221; at the end means run it in the background, like a daemon, rather than interactively.\u00c2\u00a0 Here you tell it to do nothing for 10 minutes and then then you get a list of the processes you are running.\u00c2\u00a0 See the one with PID 3984 (your pid will be different)?\u00c2\u00a0 That&#8217;s the sleeping one we are going to creep up on and kill.\u00c2\u00a0 Brutal.<\/p>\n<blockquote>\n<pre>naich@raspberrypi ~ $ <strong>kill 3984<\/strong>\r\n[1]+\u00c2\u00a0 Terminated\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 sleep 600\r\nnaich@raspberrypi ~ $ <strong>ps -fu naich<\/strong>\r\nUID\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 PID\u00c2\u00a0 PPID\u00c2\u00a0 C STIME TTY\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 TIME CMD\r\nnaich\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 3867\u00c2\u00a0 3860\u00c2\u00a0 0 11:35 ?\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 00:00:01 sshd: naich@pts\/0\r\nnaich\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 3868\u00c2\u00a0 3867\u00c2\u00a0 0 11:35 pts\/0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 00:00:02 -bash\r\nnaich\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 3985\u00c2\u00a0 3868\u00c2\u00a0 0 12:51 pts\/0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 00:00:00 ps -fu naich\r\nnaich@raspberrypi ~ $<\/pre>\n<\/blockquote>\n<p>RIP 3984.\u00c2\u00a0 Poor thing never knew what hit it.\u00c2\u00a0 If you are killing it because it has locked up, then you might need to use a bit more force.\u00c2\u00a0 If politely asking it to die with kill doesn&#8217;t work, use <strong><tt>kill -9<\/tt><\/strong> to guarantee you&#8217;ll finish it off.<\/p>\n<h4>12.3\u00c2\u00a0 Symbolic links<\/h4>\n<p>Symbolic links allow more than one filename to point to the same file or directory.\u00c2\u00a0 Similar to (and naturally predating) the Windows &#8220;shortcut&#8221;, they allow you to use a filename to point to another file or directory in a different place.\u00c2\u00a0 They come in two types &#8211; hard links and soft links.\u00c2\u00a0 A hard link creates a filename that refers to the physical location of the data.\u00c2\u00a0 It will appear as a normal file but shares the same data as the file it is linked to.\u00c2\u00a0 The more common type is a soft link, which appears as &#8220;linkname -&gt; original_file&#8221; in long listings.\u00c2\u00a0 Example:<\/p>\n<blockquote>\n<pre>naich@raspberrypi ~ $ <strong>mkdir wibble<\/strong>\r\nnaich@raspberrypi ~ $ <strong>echo hello &gt;wibble\/linktest.txt<\/strong>\r\nnaich@raspberrypi ~ $ <strong>ln -s wibble\/linktest.txt softlink<\/strong>\r\nnaich@raspberrypi ~ $ <strong>ls -l<\/strong>\r\ntotal 4\r\nlrwxrwxrwx 1 naich naich\u00c2\u00a0\u00c2\u00a0 19 Aug 24 14:22 softlink -&gt; wibble\/linktest.txt\r\ndrwxr-xr-x 2 naich naich 4096 Aug 24 14:21 wibble\r\nnaich@raspberrypi ~ $ <strong>cat softlink<\/strong>\r\nhello\r\nnaich@raspberrypi ~ $ <strong>rm softlink<\/strong>\r\nnaich@raspberrypi ~ $ <strong>ls -l wibble\/<\/strong>\r\ntotal 4\r\n-rw-r--r-- 1 naich naich 6 Aug 24 14:21 linktest.txt\r\nnaich@raspberrypi ~ $<\/pre>\n<\/blockquote>\n<p>First we make a directory called &#8220;wibble&#8221;, then create a file in it (linktest.txt) with some text in it.\u00c2\u00a0 <strong><tt>ln -s wibble\/linktest.txt softlink<\/tt><\/strong> creates a soft link to &#8220;wibble\/linktest.txt&#8221; called &#8220;softlink&#8221;.\u00c2\u00a0 We demonstrate that &#8220;softlink&#8221; can be used as a real file by outputting the contents with <strong><tt>cat softlink<\/tt><\/strong>.\u00c2\u00a0 Then we remove the softlink with <strong><tt>rm softlink<\/tt><\/strong> and show that the original file remains.<\/p>\n<p>Softlinks to directories can cause all sorts of hilarious confusion if you get a bit lost:<\/p>\n<blockquote>\n<pre>naich@raspberrypi ~ $ <strong><tt>ln -s \/ subdirectory<\/tt><\/strong>\r\nnaich@raspberrypi ~ $ <strong><tt>cd subdirectory\/home\/naich\/subdirectory\/home\/naich<\/tt><\/strong>\r\nnaich@raspberrypi ~\/subdirectory\/home\/naich\/subdirectory\/home\/naich $ <strong><tt>pwd<\/tt><\/strong>\r\n\/home\/naich\/subdirectory\/home\/naich\/subdirectory\/home\/naich\r\nnaich@raspberrypi ~\/subdirectory\/home\/naich\/subdirectory\/home\/naich $<\/pre>\n<\/blockquote>\n<p>Eek!<\/p>\n<h4>\u00c2\u00a012.4\u00c2\u00a0 Everything else<\/h4>\n<p>Some other other useful things to know about.<\/p>\n<p>There is no on switch or reset button on the Pi, so we use the &#8220;shutdown&#8221; command to reboot or halt.\u00c2\u00a0 Options are &#8220;-r&#8221; to reboot or &#8220;-h&#8221; to halt before turning it off.\u00c2\u00a0 You also specify a time to do it at, or &#8220;now&#8221; to do it immediately.<\/p>\n<blockquote>\n<pre>naich@raspberrypi ~ $ <strong>sudo shutdown -r now<\/strong>\r\n\r\nBroadcast message from root@raspberrypi (pts\/1) (Fri Aug 24 14:02:39 2012):\r\nThe system is going down for reboot NOW!\r\nnaich@raspberrypi ~ $<\/pre>\n<\/blockquote>\n<p>You can also use the commands <strong><tt>halt<\/tt><\/strong> to halt and <strong><tt>reboot<\/tt><\/strong> to wipe the SD card clean.\u00c2\u00a0 Nah, just kidding.\u00c2\u00a0 It reboots the Pi.<\/p>\n<p>For file manipulation (stop sniggering at the back), the commands are mv (move), cp (copy), rm (remove), mkdir (make directory), rmdir (remove directory).\u00c2\u00a0 <a href=\"http:\/\/linuxcommand.org\/lts0050.php\">This page<\/a> explains them in english.<\/p>\n<p>Get information about the filesystem with the commands df and du.\u00c2\u00a0 df shows how full the filesystems are:<\/p>\n<blockquote>\n<pre>naich@raspberrypi ~ $ <strong>df -h<\/strong>\r\nFilesystem\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 Size\u00c2\u00a0 Used Avail Use% Mounted on\r\nrootfs\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 3.6G\u00c2\u00a0 1.4G\u00c2\u00a0 2.1G\u00c2\u00a0 41% \/\r\n\/dev\/root\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 3.6G\u00c2\u00a0 1.4G\u00c2\u00a0 2.1G\u00c2\u00a0 41% \/\r\ntmpfs\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 22M\u00c2\u00a0 208K\u00c2\u00a0\u00c2\u00a0 22M\u00c2\u00a0\u00c2\u00a0 1% \/run\r\ntmpfs\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 5.0M\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 0\u00c2\u00a0 5.0M\u00c2\u00a0\u00c2\u00a0 0% \/run\/lock\r\ntmpfs\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 44M\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 0\u00c2\u00a0\u00c2\u00a0 44M\u00c2\u00a0\u00c2\u00a0 0% \/tmp\r\ntmpfs\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 10M\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 0\u00c2\u00a0\u00c2\u00a0 10M\u00c2\u00a0\u00c2\u00a0 0% \/dev\r\ntmpfs\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 44M\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 0\u00c2\u00a0\u00c2\u00a0 44M\u00c2\u00a0\u00c2\u00a0 0% \/run\/shm\r\n\/dev\/mmcblk0p1\u00c2\u00a0\u00c2\u00a0 56M\u00c2\u00a0\u00c2\u00a0 34M\u00c2\u00a0\u00c2\u00a0 23M\u00c2\u00a0 61% \/boot\r\n\/dev\/sda1\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 7.5G\u00c2\u00a0 2.0G\u00c2\u00a0 5.6G\u00c2\u00a0 27% \/mnt\/downloads<\/pre>\n<\/blockquote>\n<p>du shows the amount of hard disk space used in a directory and all those under it:<\/p>\n<blockquote>\n<pre>naich@raspberrypi ~ $ <strong>du -h \/etc<\/strong>\r\n132K\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 \/etc\/console-setup\r\n8.0K\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 \/etc\/rc4.d\r\n8.0K\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 \/etc\/dpkg\/origins\r\n... and on and on ...\r\n24K\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 \/etc\/gconf\r\n3.8M\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 \/etc\r\nnaich@raspberrypi ~ $<\/pre>\n<\/blockquote>\n<p>Finally, for the moment, check out <strong><tt>uptime<\/tt><\/strong>.\u00c2\u00a0 This shows how long it has been since the last reboot.\u00c2\u00a0 This is the geek equivalent of comparing penis size, so make sure you have at least a month&#8217;s worth of uptime before even mentioning it to anyone, let alone bragging about it.<\/p>\n<blockquote>\n<pre>naich@raspberrypi ~ $ uptime\r\n\u00c2\u00a015:24:09 up\u00c2\u00a0 1:21,\u00c2\u00a0 2 users,\u00c2\u00a0 load average: 0.00, 0.01, 0.05\r\nnaich@raspberrypi ~ $<\/pre>\n<\/blockquote>\n<p>Yeah, an hour and 21 minutes is <em>not<\/em> going to impress the ladies.\u00c2\u00a0 In my defense, I did have to reboot to get a screenshot earlier.\u00c2\u00a0 And it&#8217;s very cold in here.<\/p>\n<h4>12.4\u00c2\u00a0 Further reading<\/h4>\n<ul>\n<li><a href=\"http:\/\/www.raspberrypi.org\/phpBB3\/\">The Raspberry Pi Forum<\/a> &#8211; filled with clueless people like you asking questions and intelligent people answering them.<\/li>\n<li><a href=\"http:\/\/tldp.org\/LDP\/intro-linux\/html\/index.html\">A better intro to using Linux than this one<\/a> &#8211; written by people who know what they are on about.<\/li>\n<li><a href=\"http:\/\/elinux.org\/R-Pi_NAS\">Setting your Pi up as a NAS<\/a> &#8211; how to set up a Samba server on your Pi for seamless integration with Windows PCs.<\/li>\n<li><a href=\"http:\/\/tldp.org\/LDP\/Bash-Beginners-Guide\/html\/chap_01.html\">Bash scripting<\/a> &#8211; automate your tasks with bash&#8217;s powerful scripting language.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>This post is part of a short series of tutorials for people who are new to using their Raspberry Pi.\u00c2\u00a0 It will make more sense if you start at the beginning. Continued from here. First page here 12.\u00c2\u00a0 Some other useful bits and bobs Firstly, let me say that Linux is a huge subject and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[74,102],"tags":[],"class_list":["post-774","post","type-post","status-publish","format-standard","hentry","category-geek","category-raspberry-pi"],"_links":{"self":[{"href":"https:\/\/naich.net\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/774","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/naich.net\/wordpress\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/naich.net\/wordpress\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/naich.net\/wordpress\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/naich.net\/wordpress\/index.php\/wp-json\/wp\/v2\/comments?post=774"}],"version-history":[{"count":24,"href":"https:\/\/naich.net\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/774\/revisions"}],"predecessor-version":[{"id":788,"href":"https:\/\/naich.net\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/774\/revisions\/788"}],"wp:attachment":[{"href":"https:\/\/naich.net\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=774"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/naich.net\/wordpress\/index.php\/wp-json\/wp\/v2\/categories?post=774"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/naich.net\/wordpress\/index.php\/wp-json\/wp\/v2\/tags?post=774"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}