Table of Contents
Terminal Commands
Terminal Commands
- Control U - Cancels the line you're typing.
- Control C - Interrupts the program currently executing.
- Control \ - Interupts the program currently executing (stronger than control C and produces a core dump).
- Control Z - Suspends the execution of the current program (execution can be resumed later).
- Control S - Stops output sent to terminal (suspends program).
- Control Q - Restarts execution of stopped program.
Process Commands
- ps - Displays your processes
- ps -f - Displays all info on your processes.
- ps -A - Displays info on ALL processes running on the machine.
- ps -fA - Displays all info on ALL processes running on the machine.
- jobs - Displays jobs (including stopped jobs)
- kill - Used to remove a process
- kill -pid - Kills a process.
- kill %jobno - Kills a job.
- kill -s 9 pid - Kills a process by sending the KILL signal (stronger than kill -pid).
- fg - Used to restart a stopped job (move it to the forground). fg %jobno or fg pid
- bg - Used to move jobs to the backround
- bg %jobno or bg pid
REDIRECTION
- I/O includes standard input, standard output, and standard error. Redirection lets you reroute the I/O from any of these to or from a file.
- < redirect standard input
- > or 1> redirect standard output (overwrite)
- » or 1» redirect standard output (append)
- 2> redirect standard error (overwrite)
- 2» redirect standard error (append)
- Format: command < input > output
- - cat < file_in > file_out
PIPES
- Redirects output from 1 program into another.
- Format: command | command
- - ls | more
- - cat < source_file | sort
- - cat < source_file | sort > result_file
ALIASES
- Aliases can be used to define new names for commonly used commands.
alias newname=“unix_command” - Defines newname to be an alias for the UNIX command “unix_command”.
- - i.e. alias dir=“ls -la”
- unalias newname - Removes the alias newname.
- - i.e. unalias dir
- Since aliases do not remain in effect if you close the session, you can put commonly used aliases in your ”.profile” file.
LINKS
- Links allow the creation of an alias or a knick name for a file. Changes to the link affect the file and the “rm” command removes the link, but not the file. There are 2 types of links:
- 1. “hard” links - A UNIX file can have multiple “hard” links. “Hard” links and the file must be on the same file system.
- - link file linking_name
- - ln file linking_name
- 2. “soft” links - Aka symbolic link. A symbolic link can be created across file systems. A UNIX file can have multiple symbolic links. Symbolic links can also refer to a directory.
- - ln -s file linking_path/file.
- Warning symbolic links can create circular references. Deletion of the linking_path/file results in an undefined link.
- unlink - Removes a link (“hard” or “soft”).
- - unlink linked_name
PERMISSIONS
- File / directory permissions include read ®, write (w), and execute (x). Permissions can be set for the owner (u), members of the owners group (g), and all others (o). The UNIX command “chmod” is used to change permissions.
- File permissions:
- r - Required to be able to read a file.
- w - Required to be able to write a file (to edit requires r and w).
- x - Required to be able to execute a file. Shell scripts (batch files) require r and x to execute.
- Directory permissions.
- r - Lets one see what's in the directory, but nothing else.
- w - Lets one see what's in the directory, but nothing else.
- x - Required to do anything with the directory or its contents.
- To view the file permissions in your account use the “ls -la” command (list ALL files using a LONG display) or use the “ls -l” command.