Linux Commands Flashcards

You may prefer our related Brainscape-certified flashcards:
0
Q

cal

A

Shows system calendar

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
1
Q

date

A

Shows date

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

df

A

To see the current amount of free space on your disk drives

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

free

A

to display the amount of free memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

exit

A

to end a terminal session

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Ctrl- Alt-F1 through Ctrl-Alt-F6

A

To access virtual terminals or virtual consoles

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Alt and F1-F6

A

To switch from one virtual console to another

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Alt-F7

A

To return to the graphical desk- top

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

pwd

A

Print name of current working directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

cd (argument)

A

Change directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

ls

A

List current working directory contents

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

.

A

The “.” symbol refers to the working directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

..

A

the “..” symbol refers to the working directory’s parent directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

cd

A

Changes the working directory to your home directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

cd -

A

Changes the working directory to the previous working directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

cd ~user_name

A

Changes the working directory to the home directory of user_name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

ls -a

A

Shows hidden files

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

ls (arg) (arg) …

A

To list the contents of one or more directories

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

ls -l

A

By adding “-l” to the command, we changed the output to the long format

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

command -options arguments

A

Overall style of a command

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

ls -lt

A

many commands allow multiple short options to be strung together. In this example, the ls command is given two options, the “l” option to produce long format output, and the “t” option to sort the result by the file’s modification time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

ls -lt –reverse

A

Long options are preceded with two dashes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

ls -a

ls –all

A

List all files, even those with names that begin with a period, which are normally not listed (i.e., hidden)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

ls -A

ls –almost-all

A

Like the -a option above except it does not list . (current directory) and .. (parent directory)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

ls -d

ls –directory

A

Ordinarily, if a directory is specified, ls will list the contents of the directory, not the directory itself. Use this option in conjunction with the -l option to see details about the directory rather than its contents

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

ls -F

ls –classify

A

This option will append an indicator character to the end of each listed name. For example, a “/” if the name is a directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

ls -h

ls –human-readable

A

In long format listings, display file sizes in human readable format rather than in bytes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

ls -l

A

Display results in long format

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

ls -r

ls –reverse

A

Display the results in reverse order. Normally, ls displays its results in ascending alphabetical order

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

ls -S

A

Sort results by file size

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

ls -t

A

Sort by modification time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

ls Long Listing Fields:

-rw-r–r–

A

Access rights to the file. The first character indicates the type of file. Among the different types, a leading dash means a regular file, while a “d” indicates a directory.
The next three characters are the access rights for the file’s owner, the next three are for members of the file’s group, and the final three are for everyone else. The full meaning of this is discussed in Chapter 9 – Permissions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

ls Long Listing Fields:

1

A

File’s number of hard links. See the discussion of links later in this chapter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

ls Long Listing Fields:

root

A

The username of the file’s owner

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

ls Long Listing Fields:

root

A

The name of the group which owns the file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

ls Long Listing Fields:

32059

A

Size of the file in bytes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

ls Long Listing Fields:

2007-04-03 11:05

A

Date and time of the file’s last modification

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

ls Long Listing Fields:

oo-cd-cover.odf

A

Name of the file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

file (filename)

A

the file command will print a brief description of the file’s contents

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q

less (filename)

A

the less program allows you to scroll forward and backward through a text file.
Once the less program starts, we can view the contents of the file. If the file is longer
than one page, we can scroll up and down. To exit less, press the “q” key.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
40
Q

less Commands:

Page Up or b

A

Scroll back one page

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
41
Q

less Commands:

Page Down or space

A

Scroll forward one page

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
42
Q

less Commands:

Up Arrow

A

Scroll up one line

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
43
Q

less Commands:

Down Arrow

A

Scroll down one line

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
44
Q

less Commands:

G

A

Move to the end of the text file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
45
Q

less Commands:

1G or g

A

Move to the beginning of the text file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
46
Q

less Commands:

/characters

A

Search forward to the next occurrence of characters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
47
Q

less Commands:

n

A

Search for the next occurrence of the previous search

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
48
Q

less Commands:

h

A

Display help screen

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
49
Q

less Commands:

q

A

Quit less

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
50
Q

Directories Found On Linux Systems:

/

A

The root directory. Where everything begins.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
51
Q

Directories Found On Linux Systems:

/bin

A

Contains binaries (programs) that must be present for the system to boot and run.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
52
Q

Directories Found On Linux Systems:

/boot

A

Contains the Linux kernel, initial RAM disk image (for drivers needed at boot time), and the boot loader.
Interesting files:
● /boot/grub/grub.conf or menu.lst, which
are used to configure the boot loader.
● /boot/vmlinuz, the Linux kernel

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
53
Q

Directories Found On Linux Systems:

/dev

A

This is a special directory which contains device nodes. “Everything is a file” also applies to devices. Here is where the kernel maintains a list of all the devices it understands.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
54
Q

Directories Found On Linux Systems:

/etc

A

The /etc directory contains all of the system-wide configuration files. It also contains a collection of shell scripts which start each of the system services at boot time. Everything in this directory should be readable text.
Interesting files: While everything in /etc is interesting, here are some of my all-time favorites:
● /etc/crontab, a file that defines when automated jobs will run.
● /etc/fstab, a table of storage devices and their associated mount points.
● /etc/passwd, a list of the user accounts.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
55
Q

Directories Found On Linux Systems:

/home

A

In normal configurations, each user is given a directory in /home. Ordinary users can only write files in their home directories. This limitation protects the system from errant user activity.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
56
Q

Directories Found On Linux Systems:

/lib

A

Contains shared library files used by the core system programs. These are similar to DLLs in Windows.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
57
Q

Directories Found On Linux Systems:

/lost+found

A

Each formatted partition or device using a Linux file system, such as ext3, will have this directory. It is used in the case of a partial recovery from a file system corruption event. Unless something really bad has happened to your system, this directory will remain empty.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
58
Q

Directories Found On Linux Systems:

/media

A

On modern Linux systems the /media directory will contain the mount points for removable media such as USB drives, CD-ROMs, etc. that are mounted automatically at insertion.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
59
Q

Directories Found On Linux Systems:

/mnt

A

On older Linux systems, the /mnt directory contains mount points for removable devices that have been mounted
manually.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
60
Q

Directories Found On Linux Systems:

/opt

A

The /opt directory is used to install “optional” software. This is mainly used to hold commercial software products that may be installed on your system.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
61
Q

Directories Found On Linux Systems:

/proc

A

The /proc directory is special. It’s not a real file system in the sense of files stored on your hard drive. Rather, it is a virtual file system maintained by the Linux kernel. The “files” it contains are peepholes into the kernel itself. The files are readable and will give you a picture of how the kernel sees your computer.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
62
Q

Directories Found On Linux Systems:

/root

A

This is the home directory for the root account.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
63
Q

Directories Found On Linux Systems:

/sbin

A

This directory contains “system” binaries. These are programs that perform vital system tasks that are generally reserved for the superuser.

64
Q

Directories Found On Linux Systems:

/tmp

A

The /tmp directory is intended for storage of temporary, transient files created by various programs. Some configurations cause this directory to be emptied each time the system is rebooted.

65
Q

Directories Found On Linux Systems:

/usr

A

The /usr directory tree is likely the largest one on a Linux system. It contains all the programs and support files used by regular users.

66
Q

Directories Found On Linux Systems:

/usr/bin

A

/usr/bin contains the executable programs installed by your Linux distribution. It is not uncommon for this directory to hold thousands of programs.

67
Q

Directories Found On Linux Systems:

/usr/lib

A

The shared libraries for the programs in /usr/bin.

68
Q

Directories Found On Linux Systems:

/usr/local

A

The /usr/local tree is where programs that are not included with your distribution but are intended for system- wide use are installed. Programs compiled from source code are normally installed in /usr/local/bin. On a newly installed Linux system, this tree exists, but it will be empty until the system administrator puts something in it.

69
Q

Directories Found On Linux Systems:

/usr/sbin

A

Contains more system administration programs.

70
Q

Directories Found On Linux Systems:

/usr/share

A

/usr/share contains all the shared data used by programs in /usr/bin. This includes things like default configuration files, icons, screen backgrounds, sound files, etc.

71
Q

Directories Found On Linux Systems:

/usr/share/doc

A

Most packages installed on the system will include some kind of documentation. In /usr/share/doc, we will find documentation files organized by package.

72
Q

Directories Found On Linux Systems:

/var

A

With the exception of /tmp and /home, the directories we have looked at so far remain relatively static, that is, their contents don’t change. The /var directory tree is where data that is likely to change is stored. Various databases, spool files, user mail, etc. are located here.

73
Q

Directories Found On Linux Systems:

/var/log

A

/var/log contains log files, records of various system activity. These are very important and should be monitored from time to time. The most useful one is /var/log/messages. Note that for security reasons on some systems, you must be the superuser to view log files .

74
Q

Wildcards:

*

A

Matches any characters

75
Q

Wildcards:

?

A

Matches any single character

76
Q

Wildcards:

[characters]

A

Matches any character that is a member of the set characters (just one character)

77
Q

Wildcards:

[!characters]

A

Matches any character that is not a member of the set
characters

78
Q

Wildcards:

[[:class:]]

A

Matches any character that is a member of the specified class

79
Q

Commonly Used Character Classes:

[:alnum:]

A

Matches any alphanumeric character

80
Q

Commonly Used Character Classes:

[:alpha:]

A

Matches any alphabetic character

81
Q

Commonly Used Character Classes:

[:digit:]

A

Matches any numeral

82
Q

Commonly Used Character Classes:

[:lower:]

A

Matches any lowercase letter

83
Q

Commonly Used Character Classes:

[:upper:]

A

Matches any uppercase letter

84
Q

mkdir (arg)…

A

The mkdir command is used to create directories

85
Q

cp item1 item2

A

to copy the single file or directory “item1” to file or directory “item2”.
(If file2 exists, it is overwritten with the contents of file1)

86
Q

cp item… directory

A

to copy multiple items (either files or directories) into a directory.
(Directory must already exist)

87
Q

cp -a

cp –archive

A

Copy the files and directories and all of their attributes, including ownerships and permissions. Normally, copies take on the default attributes of the user performing the copy.

88
Q

cp -i

cp –interactive

A

Before overwriting an existing file, prompt the user for confirmation. If this option is not specified, cp will silently overwrite files.

89
Q

cp -r

cp –recursive

A

Recursively copy directories and their contents. This option (or the -a option) is required when copying directories.

90
Q

cp -u

cp –update

A

When copying files from one directory to another, only copy files that either don’t exist, or are newer than the existing corresponding files, in the destination directory.

91
Q

cp -v

cp –verbose

A

Display informative messages as the copy is performed.

92
Q

mv item1 item2

A

to move or rename file or directory “item1” to “item2”

93
Q

mv item… directory

A

to move one or more items from one directory to another.

94
Q

mv -i

mv –interactive

A

Before overwriting an existing file, prompt the user for confirmation. If this option is not specified, mv will silently overwrite files.

95
Q

mv -u

mv –update

A

When moving files from one directory to another, only move files that either don’t exist, or are newer than the existing corresponding files in the destination directory.

96
Q

mv -v

mv –verbose

A

Display informative messages as the move is performed.

97
Q

cp -r dir1 dir2

A

Copy the contents of directory dir1 to directory dir2. If directory dir2 does not exist, it is created and, after the copy, will contain the same contents as directory dir1.
If directory dir2 does exist, then directory dir1 (and its contents) will be copied into dir2.

98
Q

mv dir1 dir2

A

If directory dir2 does not exist, create directory dir2 and move the contents of directory dir1 into dir2 and delete directory dir1.
If directory dir2 does exist, move directory dir1 (and its contents) into directory dir2.

99
Q

rm (arg)…

A

The rm command is used to remove (delete) files and directories

100
Q

rm -i

rm –interactive

A

Before deleting an existing file, prompt the user for confirmation. If this option is not specified, rm will silently delete files.

101
Q

rm -r

rm –recursive

A

Recursively delete directories. This means that if a directory being deleted has subdirectories, delete them too. To delete a directory, this option must be specified.

102
Q

rm -f

rm –force

A

Ignore nonexistent files and do not prompt. This overrides the –interactive option.

103
Q

rm -v

rm –verbose

A

Display informative messages as the deletion is performed.

104
Q

ln file link

A

To create a hard link

105
Q

ln -s item link

A

to create a symbolic link where “item” is either a file or a directory.

106
Q

ls -i

A

Show the inode(the block chain of memory where the contents part of the file and not the name part or hard link lives) number.

107
Q

type command

A

The type command is a shell builtin that displays the kind of command the shell will
execute, given a particular command name. ( shell built in, executable program, shell function, alias)

108
Q

which command

A

Display An Executable’s Location ( works only on executable commands not other forms)

109
Q

help command

A

bash has a built-in help facility available for each of the shell builtins. To use it, type
“help” followed by the name of the shell builtin.

110
Q

command –help

A

Many executable programs support a “–help” option that displays a description of the
command’s supported syntax and options.

111
Q

man program

A

Most executable programs intended for command line use provide a formal piece of doc- umentation called a manual or man page. A special paging program called man is used to view them.

112
Q

apropos term

man -k term

A

It is also possible to search the list of man pages for possible matches based on a search term.

113
Q

whatis command

A

The whatis program displays the name and a one line description of a man page match- ing a specified keyword

114
Q

info program

A

The GNU Project provides an alternative to man pages for their programs, called “info.” Info pages are displayed with a reader program named, appropriately enough, info. Info pages are hyperlinked much like web pages.

115
Q

info Commands:

?

A

Display command help

116
Q

info Commands:

PgUp or Backspace

A

Display previous page

117
Q

info Commands:

Enter

A

Follow the hyperlink at the cursor location

118
Q

info Commands:

PgDn or Space

A

Display next page

119
Q

info Commands:

n

A

Next - Display the next node

120
Q

info Commands:

p

A

Previous - Display the previous node

121
Q

info Commands:

u

A

Up - Display the parent node of the currently displayed node, usually a menu.

122
Q

info Commands:

q

A

Quit

123
Q

info coreutils

A

will display a menu page with hyperlinks to each program contained in the coreutils
package.

124
Q

/usr/share/doc
gzip
zless

A

Many software packages installed on your system have documentation files residing in the /usr/share/doc directory. Most of these are stored in plain text format and can be viewed with less. Some of the files are in HTML format and can be viewed with a web browser. We may encounter some files ending with a “.gz” extension. This indicates that they have been compressed with the gzip compression program. The gzip package includes a special version of less called zless that will display the contents of gzip- compressed text files.

125
Q

alias name=’string’

A

After the command “alias” we give alias a name followed immediately (no whitespace al- lowed) by an equals sign, followed immediately by a quoted string containing the mean- ing to be assigned to the name. After we define our alias, it can be used anywhere the shell would expect a command.

126
Q

unalias (arg)

A

To remove an alias, the unalias command is used

127
Q

alias

A

To see all the aliases defined in the environment, use the alias command without arguments.

128
Q

>

A

To redirect standard output to another file instead of the screen, we use the “>” redirection operator followed by the name of the file.

129
Q

> file-name

A

to actually truncate a file (or create a new, empty file)

130
Q

> >

A

Using the “»” operator will result in the output being appended to the file. If the file does not already exist, it is created just as though the “>” operator had been used.

131
Q

(file descriptor)

A

A program can produce output on any of several numbered file streams. While we have referred to the first three of these file streams as standard input, output and error, the shell references them internally as file de- scriptors 0, 1 and 2, respectively. The shell provides a notation for redirecting files using the file descriptor number.

132
Q

2>

A

Since standard error is the same as file descriptor number 2, we can redirect standard error with this notation.

133
Q

example: ls -l /bin/usr > ls-output.txt 2>&1

A

Using this method, we perform two redirections. First we redirect standard output to the file ls-output.txt and then we redirect file descriptor 2 (standard error) to file de- scriptor one (standard output) using the notation 2>&1.
(Order is significant)

134
Q

example: ls -l /bin/usr &> ls-output.txt

A

In this example, we use the single notation &> to redirect both standard output and stan- dard error to the file ls-output.txt. You may also append the standard output and standard error streams to a single file like so:
ls -l /bin/usr &» ls-output.txt

135
Q

example: ls -l /bin/usr 2> /dev/null

A

Sometimes “silence is golden,” and we don’t want output from a command, we just want to throw it away. This applies particularly to error and status messages. The system pro- vides a way to do this by redirecting output to a special file called “/dev/null”. This file is a system device called a bit bucket which accepts input and does nothing with it. To sup- press error messages from a command, we do this.

136
Q

/dev/null

A

This file is a system device called a bit bucket which accepts input and does nothing with it.

137
Q

cat [file…]

A

The cat command reads one or more files and copies them to standard output.

138
Q

example: cat movie.mpeg.0* > movie.mpeg

A

Since cat can accept more than one file as an argument, it can also be used to
join files together. Say we have downloaded a large file that has been split into multiple parts (multimedia files are often split this way on Usenet), and we want to join them back together. If the files were named:
movie.mpeg.001 movie.mpeg.002 … movie.mpeg.099
we could join them back together with this command.
Since wildcards always expand in sorted order, the arguments will be arranged in the cor- rect order.

139
Q

cat

A

Enter a text by keyboard and hit Cntl-d to denote the end of the text.
If not redirected anywhere cat will send the output to screen, if redirected to a file, you have made a text file.

140
Q

cat > file

A

Cat reads its input not from keyboard but from a file.

141
Q

command1 | command2

A

Using the pipe operator “|” (vertical bar), the
standard output of one command can be piped into the standard input of another.

142
Q

sort (input…)

A

Sort lines of text.

Sophisticated example: ls /bin /usr/bin | sort | less

143
Q

uniq (input)

A

The uniq command is often used in conjunction with sort. uniq accepts a sorted list of data from either standard input or a single filename argument (see the uniq man page for details) and, by default, removes any duplicates from the list.

144
Q

uniq -d

A

If we want to see the list of duplicates instead, we add the “-d” option to uniq.

145
Q

wc

wc -l

A
The wc (word count) command is used to display the number of lines, words, and bytes
contained in files.
if executed without command line arguments, wc accepts standard input. The “-l” option limits its output to only report lines. Adding it to a pipeline is a handy way to count things.
146
Q

grep pattern [file…]

A

When grep encounters a “pattern” in the file, it prints out the lines containing it.

147
Q

grep -i

grep -v

A

“-i” which causes grep to ignore case when performing the search (normally searches are case sensitive) and “-v” which tells grep to only print lines that do not match the pattern.

148
Q

example: head -n 5 ls-output.txt
example: tail -n 5 ls-output.txt
example: ls /usr/bin | tail -n 5

A

The head command prints the first ten lines of a file and the tail command prints the last ten lines. By default, both commands print ten lines of text, but this can be adjusted with the “-n” option.

149
Q

tail -f

A

tail has an option which allows you to view files in real-time. This is useful for watch- ing the progress of log files as they are being written.
Using the “-f” option, tail continues to monitor the file and when new lines are ap- pended, they immediately appear on the display. This continues until you type Ctrl-c.

150
Q

tee

A

The tee program reads standard input and copies it to both standard output (allowing the data to continue down the pipeline) and to one or more files. This is useful for capturing a pipeline’s contents at an intermediate stage of processing.
example: ls /usr/bin | tee ls.txt | grep zip

151
Q

Tilde Expansion:

A

echo ~
/home/me

echo ~foo
/home/foo

152
Q

Arithmetic Expansion:

A

$((expression))

example: echo $(((5**2) * 3))

Operators: +, -, *, /, %, **

Operates on integers only.

153
Q

echo (arg)

A

echo is a shell builtin that performs a very simple task. It prints out its text arguments on standard out- put.

154
Q

Brace Expansion:

A

Patterns to be brace expanded may contain a leading portion called a preamble and a trailing portion called a postscript. The brace expression itself may contain either a comma-separated list of strings, or a range of integers or single characters. The pattern may not contain embedded whitespace.
Examples:
[me@linuxbox ~]$ echo Front-{A,B,C}-Back Front-A-Back Front-B-Back Front-C-Back

[me@linuxbox ~]$ echo Number_{1..5}
Number_1 Number_2 Number_3 Number_4 Number_5

[me@linuxbox ~]$ echo {01..15}
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15

[me@linuxbox ~]$ echo {001..15}
001 002 003 004 005 006 007 008 009 010 011 012 013 014 015

[me@linuxbox ~]$ echo {Z..A}
Z Y X W VU T S R Q P O N M L K J I H G F E D C B A

[me@linuxbox ~]$ echo a{A{1,2},B{3,4}}b
aA1b aA2b aB3b aB4b

mkdir {2007..2009}-{01..12}
ls
2007-01 2007-07 2008-01 2008-07 2009-01 2009-07 2007-02 2007-08 2008-02 2008-08 2009-02 2009-08 2007-03 2007-09 2008-03 2008-09 2009-03 2009-09 2007-04 2007-10 2008-04 2008-10 2009-04 2009-10 2007-05 2007-11 2008-05 2008-11 2009-05 2009-11 2007-06 2007-12 2008-06 2008-12 2009-06 2009-12

155
Q

Parameter Expansion:

A

Many of its capabilities have to do with the system’s ability to store small chunks of data and to give each chunk a name. Many such chunks, more properly called variables, are available for your examination.

example: echo $USER

To see a list of available variables, try this:
printenv | less

156
Q

Command Substitution:

A

Command substitution allows us to use the output of a command as an expansion.
Examples:
[me@linuxbox ~]$ echo $(ls)
Desktop Documents ls-output.txt Music Pictures Public Templates Videos

[me@linuxbox ~]$ ls -l $(which cp)
-rwxr-xr-x 1 root root 71516 2007-12-05 08:58 /bin/cp

[me@linuxbox ~]$ file $(ls -d /usr/bin/* | grep zip)

157
Q

example:

[me@linuxbox ~]$ ls -l which cp
-rwxr-xr-x 1 root root 71516 2007-12-05 08:58 /bin/cp

A

There is an alternate syntax for command substitution in older shell programs which is also supported in bash. It uses back-quotes instead of the dollar sign and parentheses.