Do Some Basic UNIX: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
m (23 revisions) |
||
(19 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
<h2>Some basic unix commands</h2> | |||
<h3>Want more? Try the excellent tutorials at | <h3>Want more? Try the excellent tutorials at | ||
[http://freeengineer.org/learnUNIXin10minutes.html FreeEngineer.org], | [http://freeengineer.org/learnUNIXin10minutes.html FreeEngineer.org], | ||
[http://www.mayo.edu/bir/bir/tutor.html Mayo], | [http://www.mayo.edu/bir/bir/tutor.html Mayo], | ||
[http://www.unixgeeks.org/security/newbie/unix/ UnixGeeks.org] or | [http://www.unixgeeks.org/security/newbie/unix/ UnixGeeks.org] or | ||
[http://www.isu.edu/departments/comcom/unix/workshop/unixindex.html Idaho state]</h3> | [http://www.isu.edu/departments/comcom/unix/workshop/unixindex.html Idaho state] and, of course, the [http://www.gnu.org/software/bash/manual/bashref.html bash manual]</h3> | ||
<table border="1" cellpadding="2" cellspacing="2"> | |||
<tr> | <tr> | ||
Line 17: | Line 16: | ||
<td bgcolor="paleGoldenrod"><font face="verdana,arialverdana,arial">man</font> <i>function</i></td> | <td bgcolor="paleGoldenrod"><font face="verdana,arialverdana,arial">man</font> <i>function</i></td> | ||
<td>show the manual page for a function</td> | <td>show the manual page for a function</td> | ||
</tr> | |||
<tr> | |||
<td bgcolor="paleGoldenrod"><font face="verdana,arialverdana,arial">id</font></td> | |||
<td>list your personal user id, username, and the groups you belong to.</td> | |||
</tr> | |||
<tr> | |||
<td bgcolor="paleGoldenrod"><font face="verdana,arialverdana,arial">id <i>username</i></font></td> | |||
<td>list <i>username</i>'s id, username, and the groups they belong to.</td> | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td bgcolor="paleGoldenrod"><font face="verdana,arial">top</font | <td bgcolor="paleGoldenrod"><font face="verdana,arial">top</font> | ||
<td>shows currently running processes - do not leave this running for more than 30sec (ctrl-c) | <td>shows currently running processes - do not leave this running for more than 30sec (ctrl-c) | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td bgcolor="paleGoldenrod"><font face="verdana,arial">ps</font | <td bgcolor="paleGoldenrod"><font face="verdana,arial">ps</font> | ||
<td>show the names of all running processes | <td>show the names of all running processes | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td bgcolor="paleGoldenrod"><font face="verdana,arial">mkdir</font> <i>dir_name</i | <td bgcolor="paleGoldenrod"><font face="verdana,arial">mkdir</font> <i>dir_name</i> | ||
<td>create a sub-directory of the current directory | <td>create a sub-directory of the current directory | ||
</tr> | </tr> | ||
Line 51: | Line 60: | ||
<td>change the file permissions: | <td>change the file permissions: | ||
<p>Three numbers indicate the permissions for the owner, the group and the world.</p> | <p>Three numbers indicate the permissions for the owner, the group and the world.</p> | ||
<dl> | |||
<dd type="1">1 - execute permission | <dd type="1">1 - execute permission | ||
<dd type="1">2 - write permission | <dd type="1">2 - write permission | ||
<dd type="1">4 - read permission<p> | <dd type="1">4 - read permission<p> | ||
You can add these permissions together, for example: | |||
<dl> | <dl> | ||
<dd type="1">7 - read, write, execute | <dd type="1">7 - read, write, execute | ||
Line 63: | Line 72: | ||
<dd type="1">5 - read and execute (not write) | <dd type="1">5 - read and execute (not write) | ||
</dl> | </dl> | ||
<font face="courier">chmod 777 <i>filename</i></font> | |||
<ul> | <ul> | ||
<li type="1">Give all users read, write and execute | <li type="1">Give all users read, write and execute</li> | ||
</ul> | </ul> | ||
<font face="courier">chmod 744 <i>filename</i></font> | |||
<ul> | |||
<li type="1">owner read, write, execute</li> | |||
<li type="1">group members and all others read only</li> | |||
</ul> | |||
<font face="courier">chmod 755 <i>filename</i></font> | |||
<ul> | |||
<li type="1">owner read, write, execute | |||
<li type="1">all other read and execute (but not write) | |||
</ul> | |||
<font face="courier">chmod 700 <i>filename</i></font> | |||
<ul> | |||
<li type="1">owner read, write execute | |||
<li type="1">others: no access | |||
</ul> | |||
<font face="courier">chmod -R</font> will make these changes to all of the files in any sub-directories, as well. | |||
</td> | </td> | ||
</tr> | </tr> | ||
<tr> | |||
<td bgcolor="paleGoldenrod"><font face="verdana,arial">chgrp <i>groupname filename</i></font></td> | |||
<td>change the group that has access to the file. For example: <i>chgrp bookheimergroup myWork</i> </td> | |||
</tr> | |||
<tr> | <tr> | ||
Line 137: | Line 150: | ||
<td bgcolor="paleGoldenrod"><font face="verdana,arial">*</font></td> | <td bgcolor="paleGoldenrod"><font face="verdana,arial">*</font></td> | ||
<td>unix wild card - matches all file names (except those beginning with '.') | <td>unix wild card - matches all file names (except those beginning with '.') | ||
e.g. <font face="verdana,arial">rm *</font> will remove all files from the current directory! | |||
<b><font color="#FF0000" size="+1">You will absolutely never type 'rm *'. Ever.</font></b> | |||
<i>Always type something like</i><font face="verdana,arial"> "ls *" </font>first to verify what such a wildcard will match | |||
</td> | </td> | ||
Line 157: | Line 173: | ||
<td>matches any single character</td> | <td>matches any single character</td> | ||
</tr> | </tr> | ||
Latest revision as of 03:13, 16 January 2014
Some basic unix commands
Want more? Try the excellent tutorials at FreeEngineer.org, Mayo, UnixGeeks.org or Idaho state and, of course, the bash manual
Command | Meaning |
---|---|
man function | show the manual page for a function |
id | list your personal user id, username, and the groups you belong to. |
id username | list username's id, username, and the groups they belong to. |
top | shows currently running processes - do not leave this running for more than 30sec (ctrl-c) |
ps | show the names of all running processes |
mkdir dir_name | create a sub-directory of the current directory |
rmdir dir_name | remove a directory. You must remove files in the directory first. |
cp source dest | copy a file or directory from source to dest |
rm file_name | remove a file (permanent!) |
chmod xxx file_name | change the file permissions:
Three numbers indicate the permissions for the owner, the group and the world.
|
chgrp groupname filename | change the group that has access to the file. For example: chgrp bookheimergroup myWork |
ls | list contents of current directory |
ls -l | list the contents of the directory (long form, showing sizes) |
ls dir_name | list the contents of the named directory |
cd dir_name | change to the named directory |
pwd | show the name of the current directory |
. | the current directory |
.. | the parent directory of this directory |
more file_name | print out the contents of the named (text) file |
df | show the free space on the present disk |
du | show the disk usage on the system |
* | unix wild card - matches all file names (except those beginning with '.')
e.g. rm * will remove all files from the current directory! You will absolutely never type 'rm *'. Ever. Always type something like "ls *" first to verify what such a wildcard will match |
xemacs file_name textedit file_name |
These are all text editors that are found commonly on unix systems. Most people seem to prefer xemacs, but each has its adherents. |
? | matches any single character |