20250413 Flashcards
What does file?.sh
match?
Files named file
+ 1 character + .sh
(e.g., file1.sh
, fileA.sh
)
The ?
wildcard matches exactly one character.
What does [abc]*.csv
match?
Files starting with a
, b
, or c
and ending in .csv
(e.g., a_data.csv
, c123.csv
)
The brackets []
specify a set of characters.
What does [!x]*
match?
Files that do not start with x
(e.g., apple
, test
, but not xray
)
The !
inside brackets negates the character set.
What does ???.log
match?
Files with exactly 3 characters before .log
(e.g., app.log
, xyz.log
)
The ?
wildcard matches exactly one character.
What is the option in ls
command to make it recursive?
-R
What does echo {bubble,quick,merge}sort.java
return?
bubblesort.java quicksort.java mergesort.java
How to return file3 file4 file5 file6 file7 file8 file9 file10 file11
in Linux ?
echo file{3..15}
$LOGNAME
your login name, like fashouri
How to return your shell’s previous directory, prior to the last cd command?
$OLDPWD
What does $PATH
return?
Your shell search path
What is the definition of $USER
in Linux?
$USER: Current effective user (from shell environment)
Represents the name of the user currently logged into the shell session.
What does $LOGNAME
represent in Linux?
$LOGNAME: Original login name (from system login)
This variable reflects the user’s name as it was set at login.
How do $USER
and $LOGNAME
typically compare?
They’re usually the same, but can differ after sudo
or su
$USER
may change when switching users with sudo
or su
, while $LOGNAME
remains constant.
What is an environment variable?
A key-value pair used by the operating system to configure behavior for processes.
How do you list all environment variables in Linux?
printenv
How do you view a specific environment variable, e.g., HOME?
echo $HOME
How do you temporarily set an environment variable in Linux?
export VAR_NAME='value'
How do you make an environment variable permanent?
Add export VAR_NAME='value'
to ~/.bashrc
or ~/.zshrc
and run source ~/.bashrc
or source ~/.zshrc
.
Where are permanent environment variables commonly set for Bash?
~/.bashrc
or ~/.bash_profile
Does export VAR_NAME=value
persist after you close the terminal?
No, it’s only temporary for that session.
What does the PATH environment variable do?
Specifies directories where executable programs are located.
How do you remove an environment variable for the current session?
unset VAR_NAME
What is the command to reload a shell configuration file after editing it?
source ~/.bashrc
(or the appropriate file like ~/.zshrc
)
What happens when you run cat < file.txt
?
The contents of file.txt are passed into stdin
of cat