A - Alfa | J - Juliet | S - Sierra |
B - Bravo | K - Kilo | T - Tango |
C - Charlie | L - Lima | U - Uniform |
D - Delta | M - Mike | V - Victor |
E - Echo | N - November | W - Whiskey |
F - Foxtrot | O - Oscar | X - X-ray |
G - Golf | P - Papa | Y - Yankee |
H - Hotel | Q - Quebec | Z - Zulu |
I - India | R - Romeo | 9 - Niner |
UNIX Cheat Sheet
General help |
[command] --help - gives syntax for using that command
man [command] - brings up the manual page for the command, if it exists man [command] > file.txt - dumps the manual page(s) for the command into 'file.txt' whatis [command] - gives a short description of the command. help - gives a list of commands (GNU Bash). help [command] - gives extra information on the commands listed above. |
Viewing/editing/creating a text file |
vi [filename] - opens VI text editor, if the file doesn't exist, it'll be created on saving.
(when inside vi) - using 'i' inserts - pressing 'escape' and then ':' goes back to command mode. - '/searchstring' searchs for 'searchstring' using regular expressions. - ':' followed by 'w' writes - ':' followed by 'qw' writes then quits - ':' followed by 'q' quits. - ':' followed by 'q!' quits regardless of whether changes are made. - ':' followed by 'z' undos. pico [filename] - launches the PICO editor for the filename. more [filename] - shows one screen's worth of the file at a time. less [filename] - similar to more head [filename] - Shows the first 10 lines of file, or use -n tail [filename] - Shows the last 10 lines of file, or use -n cat [filename] | more - works like more, cat concats 2 strings |
General/System commands |
su [user] - changes the login to 'user', or to the root if no 'user' is given.
date - shows the system date whoami - tells you who you're logged in as uptime - how long the computer has been running, plus other details w - shows who's logged on, what they're doing. df - how much disk space is left. du - disk usage by your login, it can also total up directories. uname -mrs - userful info about the system uname -a - all details about the system |
Desktop / X server + client |
Switchdesk {manager - gnome, Enlightenment, etc} - Switches your desktop |
What's running |
ps - what's running.
|
File system |
ls -la - list all files/directories
|
Searching |
locate [filename] - searches the system using an indexed database of files. use updatedb to update the file database
locate [filename] | sort - sorts the files alphabetically whereis [filename] - locates an application, such as 'whereis bash' find [filename] - searches the filesystem as with locate, but without a database so its slower. find /directory -atime +30 -print - searches for files not used in the past 30 days. |
Setting up links |
ln -s target linkname - creates a symbolic link, like a shortcut to the target directory or filename.
ln target linkname - creates the default hard link. Deleting this will delete the targetted file or directory. |
Network commands |
dig domainname - retrieves information about a domain, such as name servers, mx records
whois domainname - whois info on a domain finger user - gives info about a user, their group status, but can also be used over a network netstat -ape - lots of info about whos connected to your machine, what processes are doing what with sockets |
Piping |
Piping to another command is straight forward enough:
locate filename | grep /usr/local > searchresults.txt - searches for filename, runs the results through grep to filter everything without /usr/local in it, and then outputs the results to searchresults.txt | runs one application via another, and can be used multiple times e.g. cat /usr/group | more | grep root | sort > creates a new file if once doesn't already exist, overwrites the contents of the file if it does exist >> appends to the end of the file, and creates the file if one doesn't exist. < sends everything after this to the application, e.g. ./mysql -u bob -p databasename < mysqldump.sql |
Permissions and directory listing format |
groups [username] - shows what groups the user belongs to
Chmod and Chown
|
Unix file permissions calculator |
|
So add them up and you've got your user permissions for chmoding:
chmod [mode] fileordirectory - changes the permissions on a file or directory. use -r to recursively change a whole directory and its sub directories. e.g chmod 755 myfile.txt - changes the permissions on the file to 755 which is owner read,write,execute; group read,execute; other read,execute. chown [user:group] fileordirectory - changes the user and group ownership of a file or directory. Use -R to recursively change a whole directory and its sub directories. chgrp [group] fileordirectory - changes the groupownership of a file or directory. Use -R to recursively change a whole directory and its sub directories. |
0 comments:
Post a Comment