1/101
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
shell
a program that enables text-based communications between OS and user
Bourne-again shell
another name for the Bash shell
Bash Shell
also known as the Bourne Again Shell, this is the default command line interface in Linux.
csh or tcsh (enhanced)
The C-shell (csh) uses syntax similar to the syntax used in the C programming language.
ksh
The Korn Shell (ksh) was designed to take the best features of the Bourne shell and the C shell and extend them. It has a small but dedicated following among Linux users.
zsh
The Z shell (zsh) takes shell evolution further than the Korn Shell, incorporating features from earlier shells and adding still more.
username@hostname current_directory shell_type
The prompt for an interactive shell
~
When in a prompt, it represents the current user's home directory
$
shell_type meaning regular user
#
shell_type meaning root superuser
command line structure
command [option(s)/parameter(s)...] [argument(s)...]
internal command
A command that is a part of the shell and does not exist as a file on disk. There are about 30 of them. E.g. cd, set, export, ls
external command
a command that is in an individual file as a binary program or script. When run, the shell uses the PATH variable to search for an executable file with the same name as the command. Can be created by user
type
command which shows what type a command is.
$ type echo
echo is a shell builtin
$ type man
man is usr/bin/man
quoting
a feature which encapsulates data. "data", 'data', or escape characters are valid. Usually used for special characters or spaces. Each one acts differently
"data"
Double quotes take the data and treat it as regular characters. Most special characters lose meaning (all except $, \`). Variables, command substitution, and arithmetic functions can be used
$ echo I am $USER
I am tom
$ echo "I am $USER"
I am tom
$ touch new file
$ ls (simplified)
new
file
$ touch "new file"
new file
'data'
Single quotes treat ALL characters as regular characters, no exceptions
$ echo I am $USER
I am tom
$ echo 'I am $USER'
I am $USER
\
escape characters. These remove special meaning from individual characters.
$ echo $USER
carol
$ echo \$USER
$USER
echo
output text on terminal
ls
list the contents of a directory
touch
creates an empty file, or updates an existing file's modification date
hostname
change or show a system's hostname
local variables
variables available to current shell process only
environment variables
variables available both in this session and in its sub processes. Most are in capital letters (PATH, DATE, USER). Default variables are usually this type.
Can be accessed using $variable_name or at the front of a command e.g. ($: TZ=EST date)
$ variable_name=value
creates a local variable
accessing variables
putting a $ in front of variable's name access it's value
$ greeting=hello
$ echo greeting
greeting
$ echo $greeting
hello
unset variable_name
removes a variable
export
turns a local variable into an environment variable. Can be done with or after making a local variable.
$ export greeting=hey
IS THE SAME AS
$ greeting=hey
$ export greeting
PATH
variable holds a list of directories that contain executable programs. new directories can be appended by using a colon
$ PATH=$PATH:new_directory
appends new directory to the PATH variable
$ which command_name
finds where the given command is found
$ env
displays the current environment
/usr/share/doc/
Directory containing additional documentation files, such as readme files and support for third-party software.
$ man command_name
command that provides a manual ("man") page. It displays the command's documentation
--help
an option that, when run with a command, displays brief instructions about the usage of the command
Q
to exit the man page, press this key
man sections
There are 11:
1 NAME
2 SYNOPSIS
3 DESCRIPTIONS
4 OPTIONS
5 ARGUMENTS
6 FILES
7 EXAMPLES
8 SEE ALSO
9 DIAGNOSTICS
10 COPYRIGHT
11 BUGS
NAME
Command name and brief description
SYNOPSIS
Description of the command's syntax
Description
Description of the effects of the command
Options
Available options for the command
Arguments
Available arguments for the command
Files
Auxiliary files of the command
EXAMPLES
a sample of the command line with the command
SEE ALSO
Cross-references of the command
DIAGNOSTICS
warning and Error messages and what they mean
COPYRIGHT
Author(s) of the command
BUGS
any known limitations or bugs of the command
less
a command that displays content in a somewhat interactive format. search with /linux (forwards of cursor) or ?linux (backwards of cursor). Type N to jump to next match. press H for a menu.
$ info command_name
similar to man, but more detailed. hypertext formatting. Navigation is available, and links. ? opens the menu
$ locate string
outputs every name that matches the given string. Supports wildcards and regular expressions.
updatedb
a command that updates the database. Can be run if recent files aren't showing up in locate search
find path_to_search -name name_to_check
instead of maintaining and searching a database, find recursively searches a directory tree. Also supports RegEx and wildcards. Options allow filtering of output
cat
concatenates or views text files
cut
removes sections from a text file
cd
changes directory
cp
copies a file
mv
moves or renames a file
mkdir
makes a new directory
wc
counts the number of words, lines, or bytes in a file
passwd
changes a user's password
rm
deletes a file
rmdir
deletes a directory. Must be empty, unless -r in which case it deletes recursively
more
views text files one screen at a time
whereis
Displays the file path to a specified program and related manual files
head
displays the first few lines of a file
tail
displays the last few lines of a file
sort
orders a file numerically or alphabetically
tr
translates or removes characters of a file
chmod
changes a file's permissions
grep
searches within a file
pwd
print working directory (prints current location)
ls -a
reveals hidden files and directories
..
parent directory
.
current location
tree
display the hierarchical listing of a directory tree
root filesystem
the very very base of the filesystem. anything not found in /home/user is part of this
home directory
Users' "HOME" directory is usually /home/USERNAME
Not Universal
your home directory can be abbreviated using a tilde: ~
$ su - user_name
switch user to user_name. You will be prompted to input a password
cd ~
return to the user's home directory. Can also be done by using cd without arguments
~username
this specifies the home directory of username, as opposed to your own home directory. Requires permissions
ls -l
the '-l' option creates a long list
ls -lh
Long listing with Human readable file sizes
ls -d
lists directories but not contents. ls -d */ shows only subdirectories and no files
ls -t
list sorted by modification time
ls -lrt
r reverses, so this is a long list with oldest modifications first
ls -lX
Combines long list with the option to sort by file eXtension. This will, for example, group all files ending with .txt together, all files ending with .jpg together, and so on.
ls -S
sorts by file size
ls -R
displays a recursive list--includes the contents of all subdirectories
ll
an alias that gives ls -l. Long list
mkdir -p
the parent option allows creation of nested directories
$ echo hello > hello.txt
creates a hello.txt file containing "hello"
>
writes output of command to a file instead of the terminal
mv -i
this checks if you want to overwrite an existing file if the new name you're renaming a file to already exists
rm -ri
remove empty directories, prompt you before removing nonempty directories
cp -r
allows copy to work on directories
globbing
a simple pattern matching language, like regular expressions but simpler
*
matches any number of any characters, including none
?
matches any one character
[class]
matches characters in the brackets