Website Design » Basic Linux Commands
Basic Linux Commands
Linux common commands in: logical order / Alphabetical Order
ls
List files and directories
| Usage: | |
| ls -la | detailed list of all files and directories |
| ls -lah | add human readable file sizes |
| ls -lath | add sort by modification time |
#Help from the shell
man ls
ls --help
cd
Change directory
| Usage: | |
| cd /home | change directory to /home |
| cd -P /dirname | change to /dirname (but if a symbolic link change to physical directory link points to) |
| cd /usr/local/bin | move 3 directories deep to /usr/local/bin |
#Help from the shell (type these commands from the shell prompt)
man cd
clear
Clear the display
| Usage: | |
| clear | clear the display screen |
| Add link for 'cls' | ln -s `which clear` /usr/local/bin/cls |
#Help from the shell
man clear
who
Show login information
| Usage: | |
| who | shows user, terminal, login date & time |
| who -d | shows dead processes |
| who -r | prints current run level |
| who -b | Display date of last system boot |
#Help from the shell
man who
who --help
#Related Commands
w, finger
find
Find files recursively in a directory structure
| Usage: | |
| find . | list all files to display |
| find . > /tmp/filelist.txt | store same list in a file called filelist.txt |
| find /tmp -name \*.html | list all html files in /tmp directory |
#Help from the shell
man find
find --help
grep
Search file contents to match a pattern. Lines with matching patterns are output.
| Usage: | |
| grep dog file.txt | output every line containing dog in file.txt |
| grep -v dog file.txt | output every line not containing dog |
#Help from the shell
man grep
grep --help
cat
Output and concatenate file contents.
| Usage: | |
| cat file.txt | output contents of file.txt to display |
| cat -n file.txt | prefix each line with a number |
| cat file1 file2 > file3 | concatenate file1 and file2 into file3 |
#Help from the shell
man cat
cat --help
less
Display file contents one page at a time with backward and forward movement.
| Usage: | |
| less file.txt | display contents of file.txt one page at a time |
| less -P%B file.txt | display contents of file.txt with custom prompt |
#Help from the shell
man less
less --help
echo
Output a line of text to display
| Usage: | |
| echo "Part Number:" | Display Part Number: |
| echo -e \\t"Part Number:" | Insert tab in front of text |
| echo -n "Part Number:" | suppress newline |
#Help from the shell
man echo
Copyright © 2007 WebsiteDesignElixirs.com