File commands
| Command | Description |
|---|
| cat > file | places standard input into file |
| cd | change to the home directory |
| cd directory | change directory to directory |
| cp file1 file2 | copy file1 to file2 |
| head file | output the first 10 lines of file |
| ln -s file link | create symbolic link to file |
| ls | directory listing |
| ls -al | formatted directory listing of files (including hidden ones) |
| mkdir dir | create a directory called dir |
| more file | output the contents of file |
| mv file1 file2 | rename or move file1 to file2. If file2 is an existing directory, moves file1 into directory file2 |
| pwd | show current directory |
| rm file | delete file |
| rm -f file | force remove file |
| rm -r dir | delete directory dir |
| rm -rf dir | force remove directory dir — USE WITH EXTREME CAUTION |
| scp -r user@server1:directory1 user@server2:directory2 | recursively copies files between servers |
| tail file | output the last 10 lines of file |
| tail -f file | output the last 10 lines of file as it grows, starting with the last 10 lines |
| touch file | create or update file |
File Permissions
The owner, group and world permissions for files and directories can be changes using the chmod command
- 4 – read (r)
- 2 – write (w)
- 1 – execute (x)
Examples
| Command | Description |
|---|
| chmod 777 file | change permissions of file to read, write and execute for all |
| chmod 755 file | change permissions of file to rwx for owner, rx for group and world |
Searching
| Command | Description |
|---|
| grep pattern files | search for pattern in files |
| grep -r pattern dir | search recursively for pattern in dir |
| locate file | find all instances of file |
Network
| Command | Description |
|---|
| dig domain | get DNS information for domain |
| dig any @nameserver domain | get DNS information for domain held by nameserver |
| dig mx domain | get DNS mail information for domain |
| ping host/domain | ping host or domain and output results |
| whois domain | get whois information for a domain |
SSH
| Command | Description |
|---|
| ssh user@host | connect to host as user |
| ssh -p port user@host | connect to host on port port as user |
| ssh -copy -d user@host | add your key to host for user to enable a keyed or passwordless login |
Compression
| Command | Description |
|---|
| tar cf file.tar files | create a tar named file.tar containing files |
| tar xf file.tar files | extract the files from file.tar |
| tar czf file.tar.gz files | create a tar with Gzip compression |
| tar xzf file.tar.gz files | extract a tar using Gzip |
| tar cjf file.tar.bz2 files | create a tar with Bzip2 compression |
| tar xjf file.tar.bz2 files | extract a tar using Bzip2 |
| gzip file | compresses file and renames it file.gz |
| gzip -d file.gz | decompresses file.gz back to file |
Shortcuts
| Command | Description |
|---|
| Ctrl+C | halts the current command |
| Ctrl+Z | stops the current command, resume with fg in the foreground or bg in the background |
| Ctrl+D | log out of the current session, similar to exit |
| Ctrl+W | erases one word in the current line |
| Ctrl+U | erases the whole line |
| R | type to bring up a recent command |
| !! | repeats the last command |
| exit | log out of the current session |
System Info
| Command | Description |
|---|
| uptime | show current uptime |
| w | show who is online |
| whoami | show who you are logged in as |
| finger user | display information about user |
| uname -a | show kernel information |
| cat /proc/cpuinfo | show CPU information |
| cat /proc/meminfo | show memory information |
| man command | show manual for command |
| df | show disk usage |
| du | show directory space usage |
| free | show memory and swap usage |
| whereis app | show possible locations of app |
| which app | show which app will be run by default |
| whois | shows the identity of a domain or IP address |
| locate | find file or directory |
Hostway Linux commands
These commands only work for domains still on Begis
| Command | Description |
|---|
| dom domain | display web and mail server information for domain |
| dom domain -f | display hosting features for domain |
| domm domain | display mailbox information for domain |
| paccount domain | tools for managing quota/FrontPage/PHP/SSL/MySQL etc |
| sysadd server masteraccount masteraccountpassword | adds domain to a server |
| sysclone server domain masteraccount masteraccountpassword | copies a domain from one Debian server to another |
| updateWhere domain newinternalservername | notifies all of Hostway’s systems where the customer is now located |