Basic UNIX commands: Difference between revisions
From Antalya
No edit summary |
No edit summary |
||
Line 19: | Line 19: | ||
<tr> <th>Command</th> <th>What for</th> <th>Example</th> <th>What does it do?</th> </tr> | <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>[[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>[[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>[[ps]]</th> <td>List UNIX processes running</td> <td><code>ps -auxw</code></td> <td>List all processes for all users</td></tr> |
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 |