Dana Vrajitoru
C151 Multi-User Operating Systems
Linux Commands and Processes
Linux Commands
- Small utilities/programs under Linux that can take options and arguments.
- The executable (binary) for most of them can be found in /usr/bin.
- Argument: what the command applies to.
ls /usr
- Option: how do we want the command to be executed
ls –l
- Usual commands: ls, man, cat, less, cd, mkdir.
- The find command: the argument is a path. The name of the file must be specified with the option –name:
find ./ -name hw1.txt
Some Commands
- The commands start with the name of the executable (binary), followed by
options (-letter) and/or arguments.
- Example:
ls -l /usr/include
-l is an option meaning use a long listing format
/usr/include is an argument
- Some useful commands:
cd, ls, man, less, cat
grep, find, wc,
- Manipulating files and directories:
mv, rm, cp, mkdir, rmdir
- Information about the file system:
quota, du, df
More On Commands
- The options and arguments can be combined:
ls -l /usr/include
- -l is an option meaning use a long listing format
- /usr/include is an argument
- Some useful commands:
cd, ls, man, less, cat
grep, find, wc,
- Manipulating files and directories:
mv, rm, cp, mkdir, rmdir
- Information about the file system:
quota, du, df
- Some commands take more than one argument: cp requires a source
file and a destination file.
Expressions in Commands
- Current directory: .
- Parent directory: ..
- Home directory: ~
- Designating file/path names using a pattern:
the wildcard * can be matched by anything: ls ./a* lists all the files in the current directory starting with an a.
Linux Processes
- A process is any running program.
- Under Linux a process has an identity (PID), a parent process (PPID),
an owner (UID).
- To view the active processes: ps
Useful options: -A (all), -l (long list)
Also: top
- Stop the execution of a program launched from a terminal: Ctrl-c
- Stop the execution of any process: kill. The argument must be
the process id.
- The kill command send signals to processes. The signal 9 is the most
powerful.
kill -s 9 1258
Launching Jobs on Linux
- A job is any executable run from the terminal.
- The jobs can be piped: the content of one can be sent to the next with
the symbol | in between.
- The jobs are launched as foreground tasks by default - they will block
the terminal until they are done.
- To launch a job in the background, use the symbol & at the
end of the command line.
- A job can be temporarily suspended with Ctrl-z or terminated
with Ctrl-c.
- A job can be intentionally sent to the background with the command bg
or brought to the foreground with the command fg.