103.1 Work On The Command Line Flashcards
• Use single shell commands and one- line command sequences to perform basic tasks on the command line • Use and modify the shell environment including defining, referencing and exporting environment variables • Use and edit command history
bash
is a command processor that typically runs in a text window where the user types commands that cause actions. Bash can also read and execute commands from a file, called a shell script.
echo
echo command in linux is used to display line of text/string that are passed as an argument . This is a built in command that is mostly used in shell scripts and batch files to output status text to the screen or a file.
env
env is used to either print environment variables. It is also used to run a utility or command in a custom environment. In practice, env has another common use. It is often used by shell scripts to launch the correct interpreter. In this usage, the environment is typically not changed.
export
export is bash shell BUILTINS commands, which means it is part of the shell. It marks an environment variables to be exported to child-processes.
pwd
print working directory - prints the directory file path you are working in.
set
used to define and determine the values of the system environment.
unset
Unsetting or deleting a variable directs the shell to remove the variable from the list of variables that it tracks. Once you unset a variable, you cannot access the stored value in the variable.
man
An interface to the on-line reference manuals
uname
The uname Command. The uname command reports basic information about a computer’s software and hardware. When used without any options, uname reports the name, but not the version number, of the kernel (i.e., the core of the operating system).
history
m, you can run the ‘history’ command by itself and it will simply print out the bash history of the current user to the screen. Commands are numbered, with older commands at the top and newer commands at the bottom. The history is stored in the ~/.bash_history file by default.
.bash_history
f you want to access the actual file itself, just use your favorite text editor (I use emacs but you can use pluma of gedit or vimor whatever):
emacs ~/.bash_history
That is the default location if your history file. If you don’t find anything there, you may have changed the history file’s name. This is stored in the $HISTFILE variable, so print it out to check its current value:
echo $HISTFILE
Last 15 commands
You can use
history | tail -n 15
Searching for a command
Alternatively, use
history | grep “apt-get” | tail -n 15