Lesson 2 Flashcards
What is the shell?
A program that enables text based communication between the OS and the user
Name a few popular shells
BASH, csh, ksh, zsh
Describe the basic command line structure for a command
command <options> <arguments></arguments></options>
What are internal shell commands?
Built into the shell itself, things like echo, exit and cd
What are external shell commands?
Reside in binary files added to the PATH variable
What does the type command do?
Shows where the binary is located if external command or shows if it’s built in shell command
What do double quotes tell the shell?
To use the text in between the “…” as regular characters. All special characters lose their meaning except $ and \
What do single quotes tell the shell?
They revoke any special characters, it will take the string as a literal
What do escape characters tell the shell?
To remove special meaning of certain characters, for example $ removes the builtin meaning on $
How could you with touch create a file 5 times with one command?
Using the {..} operator… touch foo{1..5}
With rm how can you delete all files matching a pattern?
rm foo? deletes anything with foo and 1 additional character
When creating a local variable how can you access it’s value?
using echo and then $…so echo $foo
How to remove a local variable?
With the unset command
How can you make a local variable global?
By using the “export” command
What is the PATH variable?
stores a list of directories separated by a colon that contains executable programs eligible as external commands to the shell
what does the which command do?
Shows the path to where the binary is stored
What is the command for creating a time variable?
date
for timezone TZ=GMT date
or EST
what does the wc command do?
used to find out the number of newline count, word count, byte and character count in the files specified by the File arguments to the standard output and hold a total count for all named files.
What does the –help command do?
Most command have a –help option but it’s normally pretty brief and limited
What does the man command do?
man displays a manual for a given command like man mkdir
If something has more than 1 man page, how do you need to refer to it?
Using the category syntax, example passwd(1)
vs passwd(5)
What is the difference between man and info?
info is normally more detailed than man pages and are formatted in hypertext.
What does the locate command do?
Quickly locates anything matching a given string in the file system. Also supports wildcards for pattern matching, for example astericks
How does find differ from locate?
find searches a directory tree recursively, it doesn’t maintain a database like locate, but it does support wildcards
what does updatedb command do?
updates the locate command database
when running ls -lh will the directory sizes be correct?
No because directories are always shown as 4096 bytes, this is the size of the link
What is globbing?
Globbing is a simple pattern matching language. Linux shells use this language to refer to groups of files whos names patch a specific pattern
- matches any number of characters
? matches 1 character (not numbers)
[] matches a class of characters
what does -v do for mkdir, rm and cp?
Turns on verbose output mode
What happens if you move the mv command to move a directory into itself?
You will get an error message that it is a subdirectory of itself
how would you delete all files starting with “foo” in a directory?
rm foo*
Using cp, how can we have the copied file retain the permissions and modification time of the original?
By using the -p or –preserver options
When using mv how can you prevent overwriting files?
By using -n or –no-clobber