Ubuntu Unleashed 2019 Edition: Covering 18.04, 18.10, 19.04

(singke) #1

The Shell Command Line


Having a basic understanding of the capabilities of the shell command line
can help you write better shell scripts. If, after you have finished reading this
short introduction, you want to learn more about the command line, check out
Chapter 11, “Command-Line Master Class, Part 1.” You can use the shell
command line to perform a number of different tasks, including the
following:


    Searching   files   or  directories with    programs    using   pattern matching    or
expressions. These commands include the GNU gawk (linked as awk)
and the grep family of commands, including egrep and fgrep.

    Getting data    from    and sending data    to  a   file    or  command,    known   as  input
and output redirection.
Feeding or filtering a program’s output to another command (called using
pipes).

A shell can also have built-in job-control commands to launch the command
line as a background process, suspend a running program, selectively retrieve
or kill running or suspended programs, and perform other types of process
control.


You can run multiple commands on a single command line by using a
semicolon to separate commands:


Click here to view code image
matthew@seymour:~$ w ; free ; df
18:14:13 up 4:35, 2 users, load average: 0.97, 0.99, 1.04
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
matthew tty7 :0 13:39 4:35m 24:34 0.32s
gnome-session
matthew pts/0 :0.0 17:24 0.00s 1.19s 4.98s
gnome-terminal
total used free shared buffers
cached
Mem: 4055692 1801104 2254588 0 134096
757532
-/+ buffers/cache: 909476 3146216
Swap: 8787512 0 8787512
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 14421344 6509276 7179508 48% /
none 2020136 336 2019800 1% /dev
none 2027844 3004 2024840 1% /dev/shm
none 2027844 224 2027620 1% /var/run
none 2027844 0 2027844 0% /var/lock
none 2027844 0 2027844 0% /lib/init/rw
/dev/sda6 284593052 144336704 125799860 54% /home

Free download pdf