Environment Variables, Aliases Flashcards
When performing a long listing what do the objects show?
permissions links owner group size datemodified file/directory
i.e drwxr-xr-x. 2 cloud_user cloud_user 6 Oct 15 16:20 Desktop
How do you list files/directories?
ls
How do you list files/directories in order of size?
ls -S
i.e ls -lS
How do you do a detailed listing of files/directories?
ls -l
How do you do a reverse listing?
ls -r
How do you list a directory including its contents?
ls -R
How do you list in order of modification time?
ls -t
How do you get a listing of environment variables?
env
How do you view the directory locations bash will look in when entering a command?
echo “$PATH”
contained in the PATH environment variable
How do you reference something in the current directory?
.
i. e ./script1
* dot source
What is the command to list the current user?
whoami
What is the command to switch user?
su
i.e su user2
What is the command to switch the the root user?
su - *resets env variables
su *just switches user
What is the command to run as root interactively without the root password?
sudo -i
*useful if no root password exists (common)
What is the command to print the name of the OS?
uname
-r release -v kernel build -m/-p architecture -o os name -a all
What is the command to print the current working directory?
pwd
echo “$PWD”
What is the command to change to the home directory?
cd
cd ~
What is the command to change a directory up once
cd ..
What is the command to return to the previous directory?
cd -
*used OLDPWD env variable
echo $OLDPWD
What is the command to print a history of commands typed?
history
*located in ~/.bash_history
What is the command to print the contents of a file to the screen?
cat
How do you see the maximum commands the history file will store?
echo $HISTFILESIZE
How do you see the configuration of the history command?
echo $HISTCONTROL
i.e ignoredups *ignores consecutively repeated commands
How do you execute a specific command in denoted in history?
!
i.e !14
What configuration scripts are executed upon signing in through the login shell?
1 /etc/profile - sets up environment variables
2 ~/.bash_profile | ~/.bash_login | ~/.profile - first file executed, sets up user env variables
3 ~/.bashrc - sets up user created functions and command aliases
4 /etc/bashrc - sets up system wide functions and command aliases
What script will be executed at user logout if it exists?
~/.bash_logout
*user defined commands can be placed here to perform actions at logout
What configuration scripts are executed upon opening a non login shell (standard)?
1 ~/.bashrc - sets up user created functions and commands
2 /etc/bashrc - sets up system wide functions and command aliases
How do you modify the $PATH env variable?
append: PATH=$PATH:/directory
prepend: PATH=/directory:$PATH
How do you create a variable and use it in other shells?
export VARIABLENAME
What is the structure that constitutes a command?
Command Option Argument
i.e ls -l file
What is the command to create an alias?
alias =’’
i.e alias lr=’ls -R’
What is the command to remove a created alias?
unalias
i.e unalias lr
How do you create a persistent alias?
Append alias to ~/.bashrc
How do you get a listing of shell and environment variables?
set