Intro to Command Line Flashcards
Difference between /home/ubuntu and home/ubuntu
/home/ubuntu This path specifies a folder called “ubuntu” that lives under your root directory, then home directory.
home/ubuntu This path specifies a completely different folder. This path means there’s a folder called “ubuntu” that lives in a directory called “home”, which is itself in the current directory.
difference between ls and ls/
ls just shows list of current directory. ls/ shows list of root directory
Display contents of a file in an interactive way
less
Display documentation about a command
man
Display last part of a file
tail
How do display contents of a file?
cat
How do you create a file in the CLI?
touch
How to copy a file in CLI
cp
How to Display contents of a file, starting at the top and letting the user scroll down?
more
How to display first part of a file
head
How would you list any files or folders that end in ‘ot’?
ls /*ot
What does the ~ symbol mean?
~ - Your “home” directory, or the directory you are placed in when you log in.
What makes an executable different from other files?
3 reasons
- They have special characters at the beginning to tell the computer how to execute them.
- They have scripts or machine language as their content.
- They have the executable permission
How to list hidden files (dotfiles) in the current directory?
ls -a ~
What’s the difference between abc/ and /abc?
The path abc/ (also ./abc and ./abc/) are paths relative to your current working directory. The path /abc, however, is the file or directory abc in the root directory.
How To figure out a default executable’s location?
which
How to re-initialize a particular environment file (such as .bashrc)
source ~/.bashrc
To have a variable get interpolated, do you use single or double quotation marks?
Double quotation marks.
Example:
$ MESSAGE1="This is message 1." $ MESSAGE2="This is message 2." $ MESSAGE="$MESSAGE1 $MESSAGE2" $ echo $MESSAGE This is message 1. This is message 2.
What does the PATH variable do?
The PATH variable determines which directories are searched when a command is entered
You can add to PATH to make more commands available without having to memorize their exact path
Modifications to PATH, or any environment variable, on the fly will not be permanent; permanent modifications should be done in an environment file, like .bashrc
What does»_space; do?
The redirection operator (») is used to append text to a file. If the target file doesn’t exist, then it will be created.
But why use sudo instead of just logging in as root? leave your Terminal open on accident.
There are several reasons for doing this, including the following:
The server administrator wants you to have root access for some commands and/or directories, but not for everything. In this case the administrator will set up sudo to have restrictions or whitelisted commands.
Running commands while logged in as root can be dangerous. Using a non-root user makes it obvious when you are running a command that requires root privileges because you have to prefix your command with sudo.
The sudo command provides a detailed audit trail so that system administrators can track what commands individuals used on system files.
Sudo uses a ticketing system where you put in your password once, then you don’t have to until you haven’t run any sudo commands for five minutes or longer. This adds security to your command line session, preventing others from gaining root access if you
What does a REPL stand for?
Interfaces that Read Input, Evaluate Input, Print results and Loop back
What are some examples of REPL interfaces?
mysql, ruby, python, or editors like vim and nano