Difference between revisions of "Linux Tips and Tricks"
Line 7: | Line 7: | ||
- Similarly tcsh is an update to csh, the C Shell (up-arrow to get last command) | - Similarly tcsh is an update to csh, the C Shell (up-arrow to get last command) | ||
− | ====• man = “manual” = the way you get help, e.g., “man ls”=== | + | ====• man = “manual” = the way you get help, e.g., “man ls”==== |
====• Working with directories: cd, pwd, ls, mkdir, rmdir==== | ====• Working with directories: cd, pwd, ls, mkdir, rmdir==== |
Revision as of 19:35, 18 September 2015
Unix/Linux Commands to Know and Cherish (with many thanks to Steve Lantz, CAC)
• Shell: bash or tcsh
- The shell defines many of the commands you enter at the command line - The Bourne Again Shell is an update to the original Bourne shell (sh) - Similarly tcsh is an update to csh, the C Shell (up-arrow to get last command)
• man = “manual” = the way you get help, e.g., “man ls”
• Working with directories: cd, pwd, ls, mkdir, rmdir
- cd to change directory (popd, pushd to use directory stack); “cd ..” = up one level - pwd = print working directory = print your current location (also known as .) - “ls -l” gives you complete directory listing, “ls -a” lets you see .prefix-files - mkdir to create a new directory, rmdir to remove an existing one
• Environment variables: export (bash, sh) or setenv (tcsh, csh)
- Variables that are local to the shell are defined with “set” - Env variables are inherited by shells started in the parent shell - Type “set” to see locals, “env” to see environment
• To view an environment variable: “echo $varname”
• Move, copy, remove files: mv, cp, rm
• To view the contents of a file: “cat filename”
- cat = “concatenate to standard output”, stdout is the terminal by default
• Redirect stdout using symbols
- “cat file1 > file2” replaces (clobbers) file2 with the contents of file1 - “cat file1 >> file2” appends file2 with the contents of file1 - “cmd1 | cmd2” to pipe stdout of cmd1 to stdin of cmd2
• Text editors: vi, emacs
- Terminal window becomes plain text editor - No graphical interface, all editing done via special key sequences
• Controlling processes
- control sequences: ctrl-c = kill, ctrl-z = suspend - bg to put process in background, fg to bring to foreground, “jobs” to see bg list