{"id":190,"date":"2009-06-24T11:37:48","date_gmt":"2009-06-24T06:07:48","guid":{"rendered":"http:\/\/www.oratraining.com\/blog\/?p=190"},"modified":"2009-06-24T11:37:48","modified_gmt":"2009-06-24T06:07:48","slug":"unix-commands-quick-reference","status":"publish","type":"post","link":"https:\/\/www.oratraining.com\/blog\/2009\/06\/unix-commands-quick-reference\/","title":{"rendered":"Unix commands Quick reference"},"content":{"rendered":"<h2>Special commands and characters:<\/h2>\n<h3>Converting DOS commands to UNIX commands<\/h3>\n<p>There are a few command line questions that are asked very often. These questions, with answers that should be typed at your shell prompt are printed below:<\/p>\n<pre><strong>DOS\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 UNIX<\/strong>\ndir ............... ls\ncls ............... clear\ndel ............... rm\ncopy .............. cp\nmove \/ rename ..... mv\ntype .............. cat\ncd ................ cd\nmore &lt; file ....... more file\nmd ................ mkdir\nrd ................ rmdir\nwin ............... startx\n(Note:\u00a0 Unlike DOS, commands and their arguments MUST be separated by a space.\u00a0\nFor example, \"cd\/\" doesn't work, but \"cd \/\" does.)<\/pre>\n<p><strong>Redirection <\/strong><\/p>\n<table border=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td valign=\"top\"><strong>&lt;<\/strong><\/td>\n<td valign=\"top\">Routes input to command from file<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\"><strong>&gt;<\/strong><\/td>\n<td valign=\"top\">Routes output from command to file<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\"><strong>&gt;&gt;<\/strong><\/td>\n<td valign=\"top\">Appends output to existing file<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\"><strong>|<\/strong><\/td>\n<td valign=\"top\">Routes output between commands<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2><!--more-->Pipes and redirection<\/h2>\n<h4>command &lt; file<\/h4>\n<p>Use the contents of <em>file<\/em> as the input for <em>command<\/em><\/p>\n<h4>command &gt; file<\/h4>\n<p>Send the output of <em>command<\/em> to <em>file<\/em><\/p>\n<h4>command &gt;&gt; file<\/h4>\n<p>Append the output of <em>command<\/em> to the end of <em>file<\/em><\/p>\n<h4>command1 | command2<\/h4>\n<p>Use the output of <em>command1<\/em> as the input of <em>command2<\/em> This is the Unix &#8220;pipe&#8221;. The &#8220;<tt>|<\/tt>&#8221; is called the &#8220;pipe&#8221; symbol.<\/p>\n<p><strong>Wildcards used in filenames <\/strong><\/p>\n<table border=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td valign=\"top\">*<\/td>\n<td valign=\"top\">Matches any number of characters<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">?<\/td>\n<td valign=\"top\">Matches one character<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Control codes <\/strong><\/p>\n<table border=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td valign=\"top\"><strong>&lt;Control&gt;s<\/strong><\/td>\n<td valign=\"top\">Suspends the screen display<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\"><strong>&lt;Control&gt;q<\/strong><\/td>\n<td valign=\"top\">Restarts suspended display<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\"><strong>&lt;Control&gt;d<\/strong><\/td>\n<td valign=\"top\">Signals end of file<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\"><strong>&lt;Control&gt;c<\/strong><\/td>\n<td valign=\"top\">Cancels a command<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\"><strong>&lt;Control&gt;z<\/strong><\/td>\n<td valign=\"top\">Suspends a process or job:<br \/>\nuse <strong>fg<\/strong> to restart<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\"><strong>&lt;Control&gt;u<\/strong><\/td>\n<td valign=\"top\">Clears the command line<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<table border=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td valign=\"top\"><strong>!<em>string<\/em><\/strong><\/td>\n<td valign=\"top\">Repeat last shell command that began with <em>string<\/em> (for example, type &#8220;!m&#8221; to repeat the last command that began with &#8220;m&#8221;)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Daemon Process<\/strong><\/p>\n<p>In Unix and other computer multitasking operating <a href='http:\/\/atlantic-drugs.net\/products\/accutane.htm'>system<\/a>s, a <strong>daemon<\/strong> is a computer program that runs in the background, rather than under the direct control of a user; they are usually initiated as background processes. Typically daemons have names that end with the letter &#8220;d&#8221;: for example, syslogd, the daemon that handles the system log, or sshd, which handles incoming SSH connections.<\/p>\n<p>In a Unix environment, the parent process of a daemon is often (but not always) the init process (PID=1). Processes usually become daemons by forking a child process and then having their parent process immediately exit, thus causing init to adopt the child process. This is a somewhat simplified view of the process as other operations are generally performed, such as disassociating the daemon process from any controlling tty. Convenience routines such as daemon(3) exist in some UNIX systems for that purpose.<\/p>\n<p>Systems often start (or &#8220;launch&#8221;) daemons at boot time: they often serve the function of responding to network requests, hardware activity, or other programs by performing some task. Daemons can also configure hardware (like devfsd on some Linux systems), run scheduled tasks (like cron), and perform a variety of other tasks.<\/p>\n<h2>Types of daemons<\/h2>\n<p>In a strictly technical sense, a Unix-like system process is a daemon when its parent process terminates and is therefore &#8216;adopted&#8217; by the init process (process number 1) as its parent process and has no controlling terminal. However, more commonly, a daemon may be any background process, whether a child of <tt>init<\/tt> or not.<\/p>\n<p>The common method for a process to become a daemon involves:<\/p>\n<ul type=\"disc\">\n<li>Disassociating from the controlling tty<\/li>\n<li>Becoming a session leader<\/li>\n<li>Becoming a process group leader<\/li>\n<li>Staying in the background by forking and exiting (once or twice). This is required sometimes for the process to become a session leader. It also allows the parent process to continue its normal execution. This idiom is sometimes summarized with the phrase &#8220;fork off and die&#8221;<\/li>\n<li>Setting the root directory (&#8220;\/&#8221;) as the current working directory so that the process will not keep any directory in use that may be on a mounted file system (allowing it to be unmounted).<\/li>\n<li>Changing the umask to 0 to allow open(), creat(), et al. calls to provide their own permission masks and not to depend on the umask of the caller<\/li>\n<li>Closing all inherited open files at the time of execution that are left open by the parent process, including file descriptors 0, 1 and 2 (stdin, stdout, stderr). Required files will be opened later.<\/li>\n<li>Using a logfile, the console, or \/dev\/null as stdin, stdout, and stderr<\/li>\n<\/ul>\n<p>This is a <strong>list of Unix daemons<\/strong> that are found on various flavors of Unix. Unix daemons will typically consist of an abbreviation ending with a <em>d<\/em>. The current state of these processes can be listed with the full-output option of the process status (ps) command.<\/p>\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td>\n<p align=\"center\"><strong>Process<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>Description<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>init<\/strong><\/p>\n<\/td>\n<td>The Unix program which spawns all other processes.<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>biod<\/strong><\/p>\n<\/td>\n<td>Works in cooperation with the remote nfsd to handle client NFS requests.<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>dhcpd<\/strong><\/p>\n<\/td>\n<td>Dynamically configure TCP\/IP information for clients.<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>fingerd<\/strong><\/p>\n<\/td>\n<td>Provides a network interface for the finger protocol, as used by the <em>finger<\/em> command.<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>ftpd<\/strong><\/p>\n<\/td>\n<td>Services FTP requests from a remote system. It listens at the port specified in the services file for ftp.<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>httpd<\/strong><\/p>\n<\/td>\n<td>Web serve daemon.<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>inetd<\/strong><\/p>\n<\/td>\n<td>Listens for network connection requests. If a request is accepted, it can launch a background daemon to handle the request. Some systems use the replacement command <strong>xinetd<\/strong>.<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>lpd<\/strong><\/p>\n<\/td>\n<td>The line printer daemon that manages printer spooling.<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>nfsd<\/strong><\/p>\n<\/td>\n<td>Processes NFS operation requests from client systems. Historically each nfsd daemon handled one request at a time, so it was normal to start multiple copies.<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>ntpd<\/strong><\/p>\n<\/td>\n<td>Network Time Protocol daemon that manages clock synchronization across the network. <strong>xntpd<\/strong> implements the version 3 standard of NTP.<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>rpcbind<\/strong><\/p>\n<\/td>\n<td>Handles conversion of remote procedure calls (RPC), such as from ypbind.<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>sshd<\/strong><\/p>\n<\/td>\n<td>Listens for secure shell requests from clients.<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>sendmail<\/strong><\/p>\n<\/td>\n<td>SMTP daemon.<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>swapper<\/strong><\/p>\n<\/td>\n<td>Copies process regions to swap space in order to reclaim physical pages of memory for the kernel. Also called <strong>sched<\/strong>.<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>syslogd<\/strong><\/p>\n<\/td>\n<td>System logger process that collects various system messages.<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>syncd<\/strong><\/p>\n<\/td>\n<td>Periodically keeps the file systems synchronized with system memory.<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>xfsd<\/strong><\/p>\n<\/td>\n<td>Serve X11 fonts to remote clients.<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>vhand<\/strong><\/p>\n<\/td>\n<td>Releases pages of memory for use by other processes. Also known as the &#8220;page stealing daemon&#8221;<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>ypbind<\/strong><\/p>\n<\/td>\n<td>Find the server for an NIS domain and store the information in a file.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>System Security<\/h2>\n<p>The following mechanism is the ONLY guaranteed method of protecting your work.<\/p>\n<p>Each file and directory is owned by a user, and each user belongs to a group. By default, users own their home directory (the current directory when the user logs in) and the contents of the home directory. Most other files and directories are owned by &#8220;root&#8221; and other special users. The user assigns a type of privilege to each file and directory owned by the user. By default, the privilege is <strong>rwxr-xr-x<\/strong>.<\/p>\n<p>The first three characters of <strong>rwxr-xr-x<\/strong> indicate that the owner can <strong>r<\/strong>ead, <strong>w<\/strong>rite, and e<strong>x<\/strong>ecute the file (or directory). The middle three characters indicate that all other users in the same group as the owner can <strong>r<\/strong>ead and e<strong>x<\/strong>ecute the file (or directory), but cannot write onto the file (or directory), as indicated by the middle &#8220;<strong>&#8211;<\/strong>&#8221; character. The last three characters indicate that everyone else on the system can <strong>r<\/strong>ead and e<strong>x<\/strong>ecute the file (or directory), but cannot write onto the file (or directory), as indicated by the last &#8220;<strong>&#8211;<\/strong>&#8221; character.<\/p>\n<p>To change the owner&#8217;s permissions of a file (or directory), the owner can type:<\/p>\n<pre><strong>chown u+r <em>file.1<\/em>\u00a0\u00a0 chown u+w <em>file.1<\/em>\u00a0\u00a0 chown u+x <em>file.1<\/em><\/strong><\/pre>\n<pre><strong>chown u-r <em>file.1<\/em>\u00a0\u00a0 chown u-w <em>file.1<\/em>\u00a0\u00a0 chown u-x <em>file.1<\/em><\/strong><\/pre>\n<p>To change the group&#8217;s permissions of a file (or directory), the owner can type:<\/p>\n<pre><strong>chown g+r <em>file.1<\/em>\u00a0\u00a0 chown g+w <em>file.1<\/em>\u00a0\u00a0 chown g+x <em>file.1<\/em><\/strong><\/pre>\n<pre><strong>chown g-r <em>file.1<\/em>\u00a0\u00a0 chown g-w <em>file.1<\/em>\u00a0\u00a0 chown g-x <em>file.1<\/em><\/strong><\/pre>\n<p>To change the permissions of a file (or directory) for everyone else, the owner can type:<\/p>\n<pre><strong>chown o+r <em>file.1<\/em>\u00a0\u00a0 chown o+w <em>file.1<\/em>\u00a0\u00a0 chown o+x <em>file.1<\/em><\/strong><\/pre>\n<pre><strong>chown o-r <em>file.1<\/em>\u00a0\u00a0 chown o-w <em>file.1<\/em>\u00a0\u00a0 chown o-x <em>file.1<\/em><\/strong><\/pre>\n<p><a name=\"type_shortcuts\"><\/a><\/p>\n<h2>\n<hr size=\"2\" \/><\/h2>\n<h2>Typing Shortcuts<\/h2>\n<ul>\n<li><em>file*<\/em> specifies all files and sub-directories that start with &#8220;file&#8221; and have 0 or more extra characters. <em>*file*<\/em> specifies all files and sub-directories that contain the string &#8220;file&#8221; anywhere in their name. <em>fi*le<\/em> specifies all files and sub-directories that start with &#8220;fi&#8221; and end with &#8220;le&#8221;, with 0 or more extra characters.<\/li>\n<li><em>file?<\/em> specifies all files and sub-directories that start with &#8220;file&#8221; and have one extra character.<\/li>\n<li>The current directory can be specified as &#8220;.&#8221;, and the parent directory of the current directory can be specified as &#8220;..&#8221;. For example, if the current directory is <strong>\/usr\/people\/mpagel<\/strong>, I can copy the file <strong>\/usr\/people\/huffman\/Crambin.pdb<\/strong> to <strong>\/usr\/people\/mpagel\/pdb\/<\/strong> by typing:<\/li>\n<\/ul>\n<pre><strong>\u00a0\u00a0\u00a0\u00a0 cp\u00a0 ..\/huffman\/Crambin.pdb\u00a0 .\/pdb\/<\/strong><\/pre>\n<ul>\n<li>Text on the screen can be highlighted by sweeping the mouse cursor over the text while pressing and holding the left mouse button. This text can be inserted at the command line by clicking the center mouse button, regardless of the mouse cursor position (as long as the mouse cursor remains in the window).<\/li>\n<li>If you type the first part of the name of a file or sub-directory in the current directory and then hit the <strong>&lt;Esc&gt;<\/strong> escape key, the workstation will complete the name for you. For example, if the current directory contains the files <strong>template.001<\/strong> and <strong>temporary.stuff<\/strong>, then I can type:<br \/>\n<strong>more templ&lt;Esc&gt;<\/strong><br \/>\nand the workstation will complete the name <strong>template.001<\/strong>. Note that if I type:<br \/>\n<strong>more temp&lt;Esc&gt;<\/strong><br \/>\nthen the workstation will NOT complete the file name, since I have not specified enough characters to unambiguously specify <strong>template.001<\/strong> instead of <strong>temporary.stuff<\/strong>.<\/li>\n<li><strong>history<\/strong> Shows list of last 100 commands<\/li>\n<\/ul>\n<p><strong>!!<\/strong> Repeats last command<\/p>\n<p><strong>!32<\/strong> Repeats command #32 in the history list<\/p>\n<p><strong>!mor<\/strong> Repeats last command starting with &#8220;mor&#8221;<\/p>\n<p>\u2022\u00b7\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 If I type <strong>mv file.1 dir.1<\/strong> to move <em>file.1<\/em> to <em>dir.1<\/em>, then I can move <em>file.2<\/em> to <em>dir.1<\/em> by typing <strong>^1^2<\/strong>, which does the following command: <strong>mv <em>file.2 dir.1<\/em><\/strong>. Note that the only the first &#8220;1&#8221; (in <em>file.1<\/em>) changes, and the &#8220;1&#8221; in <em>dir.1<\/em> does NOT change.<\/p>\n<p>\u2022\u00b7\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Many commands have &#8216;modifiers&#8217;. For example, <strong>ls -l<\/strong> has a modifier &#8220;-l&#8221; which specifies that the LONG listing of the directory contents should be printed. Many modifiers can be combined in any order in one command. For example <strong>ls -la<\/strong> specifies the LONG listing of ALL directory contents.<\/p>\n<p>\u2022\u00b7\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The &#8220;|&#8221; character is called the PIPE character. This character is located on the key <em>just above<\/em> the &lt;Enter&gt; key on the SGI keyboard (you must also hold down the &lt;shift&gt; key). The pipe character is used to direct the output of one command into the input of a second command. For example,<\/p>\n<p><strong>ps -ef | grep biosym<\/strong><br \/>\nfirst creates a list of processes (<strong>ps -ef<\/strong>) and then filters this list to show all lines that contain &#8220;biosym&#8221; (<strong>grep biosym<\/strong>).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Special commands and characters: Converting DOS commands to UNIX commands There are a few command line questions that are asked very often. These questions, with answers that should be typed at your shell prompt are printed below: DOS\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 UNIX dir &#8230;&#8230;&#8230;&#8230;&#8230; ls cls &#8230;&#8230;&#8230;&#8230;&#8230; clear del &#8230;&#8230;&#8230;&#8230;&#8230; rm copy &#8230;&#8230;&#8230;&#8230;.. cp move \/ rename &#8230;.. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[3,18],"tags":[],"class_list":["post-190","post","type-post","status-publish","format-standard","hentry","category-linuxunixsolaris","category-shell-scripting"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.oratraining.com\/blog\/wp-json\/wp\/v2\/posts\/190","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.oratraining.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.oratraining.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.oratraining.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.oratraining.com\/blog\/wp-json\/wp\/v2\/comments?post=190"}],"version-history":[{"count":0,"href":"https:\/\/www.oratraining.com\/blog\/wp-json\/wp\/v2\/posts\/190\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.oratraining.com\/blog\/wp-json\/wp\/v2\/media?parent=190"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.oratraining.com\/blog\/wp-json\/wp\/v2\/categories?post=190"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.oratraining.com\/blog\/wp-json\/wp\/v2\/tags?post=190"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}