Basic UNIX commands: Difference between revisions
From Antalya
(Created page with "<table class="table table-striped"> <tr> <th>Command</th> <th>What for</th> <th>Advanced version</th> <th>What does it do?</th> </tr> <...") |
No edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
Here is a list of some common [[UNIX]] commands. This should get you started. | |||
===The bare essentials=== | |||
<table class="table table-striped"> | <table class="table table-striped"> | ||
<tr> <th>Command</th> <th>What for</th> <th>Advanced version</th> <th>What does it do?</th> </tr> | <tr> <th>Command</th> <th>What for</th> <th>Advanced version</th> <th>What does it do?</th> </tr> | ||
<tr> <td><kbd>man</kbd></th> <td>manual for UNIX commands</td> <td><code>man man</code></td> <td>First command to learn, manual on manual</td></tr> | |||
<tr> <td><kbd>ls</kbd></th> <td>list contents of directory</td> <td><code>ls -latr</code></td> <td>list all files with more information, sort in reverse order than when it was created</td></tr> | <tr> <td><kbd>ls</kbd></th> <td>list contents of directory</td> <td><code>ls -latr</code></td> <td>list all files with more information, sort in reverse order than when it was created</td></tr> | ||
<tr> <td><kbd>cd</kbd></th> <td>change directory</td> <td><code>cd -</code></td> <td>change to the last directory you were in</td></tr> | <tr> <td><kbd>cd</kbd></th> <td>change directory</td> <td><code>cd -</code></td> <td>change to the last directory you were in</td></tr> | ||
Line 6: | Line 11: | ||
<tr> <td><kbd>mv</kbd></th> <td>move file (change name)</td> <td><code>mv -i</code></td> <td>move but ask if you are overwriting an existing file</td></tr> | <tr> <td><kbd>mv</kbd></th> <td>move file (change name)</td> <td><code>mv -i</code></td> <td>move but ask if you are overwriting an existing file</td></tr> | ||
<tr> <td><kbd>rm</kbd></th> <td>remove (delete)</td> <td><code>rm -rf *</code></td> <td>delete everything, without asking and without mercy (very dangerous)</td></tr> | <tr> <td><kbd>rm</kbd></th> <td>remove (delete)</td> <td><code>rm -rf *</code></td> <td>delete everything, without asking and without mercy (very dangerous)</td></tr> | ||
<tr> <td><kbd>less</kbd></th> <td>view an ASCII file</td> <td></td> | <tr> <td><kbd>less</kbd></th> <td>view an ASCII file</td> <td><code>less -S a.txt</code></td> <td>View <code>a.txt</code> without wrapping long lines</td></tr> | ||
</table> | </table> | ||
---- | |||
=== More involved commands === | |||
<table class="table table-striped"> | |||
<tr> <th>Command</th> <th>What for</th> <th>Example</th> <th>What does it do?</th> </tr> | |||
<tr> <th>[[chmod]]</th> <td>Change access permissions in UNIX</td> <td><code>chmod 755 a.txt</code></td> <td>Allows everyone to read and execute the file <code>a.txt</code></td></tr> | |||
<tr> <th>[[diff]]</th> <td>compare two files and list differences</td> <td><code>diff a b</code></td> <td>COmpare the two files <code>a</code> and <code>b</code> and list differences</td></tr> | |||
<tr> <th>[[grep]]</th> <td>print lines that match a pattern</td> <td><code>grep -i err a.log</code></td> <td>Print all the lines in the file <code>a.log</code> that contain <code>err</code> written big or small.</td></tr> | |||
<tr> <th>[[ps]]</th> <td>List UNIX processes running</td> <td><code>ps -auxw</code></td> <td>List all processes for all users</td></tr> | |||
<tr> <th>[[sort]]</th> <td>Sort text files line by line</td> <td><code>sort -nr a.txt</code></td> <td>Sort lines of <code>a.txt</code> in reverse numerical order</td></tr> | |||
</table> | |||
---- | |||
=== UNIX tools that are very powerful === | |||
<table class="table table-striped"> | |||
<tr> <th>Tool</th> <th>What is it used for</th> </tr> | |||
<tr> <th>[[awk]]</th> <td>modify files based on patterns</td> </tr> | |||
<tr> <th>[[find]]</th> <td>look for files that match a criteria</td> </tr> | |||
<tr> <th>[[sed]]</th> <td>replaces strings in text file</td> </tr> | |||
<tr> <th>[[vi]]</th> <td>Standard UNIX text editor</td> </tr> | |||
</table> | |||
---- | |||
[[Category:Unix]] |
Latest revision as of 20:23, 29 December 2020
Here is a list of some common UNIX commands. This should get you started.
The bare essentials
Command | What for | Advanced version | What does it do? |
---|---|---|---|
man | manual for UNIX commands | man man | First command to learn, manual on manual |
ls | list contents of directory | ls -latr | list all files with more information, sort in reverse order than when it was created |
cd | change directory | cd - | change to the last directory you were in |
cp | copy files/directories | cp -a | copy while preserving all properties |
mv | move file (change name) | mv -i | move but ask if you are overwriting an existing file |
rm | remove (delete) | rm -rf * | delete everything, without asking and without mercy (very dangerous) |
less | view an ASCII file | less -S a.txt | View a.txt without wrapping long lines |
More involved commands
Command | What for | Example | What does it do? |
---|---|---|---|
chmod | Change access permissions in UNIX | chmod 755 a.txt | Allows everyone to read and execute the file a.txt |
diff | compare two files and list differences | diff a b | COmpare the two files a and b and list differences |
grep | print lines that match a pattern | grep -i err a.log | Print all the lines in the file a.log that contain err written big or small. |
ps | List UNIX processes running | ps -auxw | List all processes for all users |
sort | Sort text files line by line | sort -nr a.txt | Sort lines of a.txt in reverse numerical order |
UNIX tools that are very powerful
Tool | What is it used for |
---|---|
awk | modify files based on patterns |
find | look for files that match a criteria |
sed | replaces strings in text file |
vi | Standard UNIX text editor |