Lesson 6 - Managing Linux and macOS Flashcards
What is a shell?
A shell is a system component providing a command interpreter by which the user can use a kernel interface and operate the OS.
What is a terminal?
A terminal is a software that implements input and output for a command shell.
What is a console?
A console is a device the implements input and output for a command shell. In Linux, multiple virtual consoles support use of a single host by multiple user sessions simultaneously.
What is the standard format for Linux commands?
- The first “word” input is interpreted as the command. This could be a full or relative path to the executable or just the name of an executable stored in a directory identified by a PATH environment variable. The command word is completed by the first space character.
- Options (switches) are used to change the operation of a command. An option can be a single letter (preceded by a single hyphen) or a word (preceded by a double hyphen). The order in which the options are placed on the command in not important.
- Arguments are values supplied to the command for it to operate on, such as file names. Arguments must be supplied in the correct order for the command’s syntax
Are Linux commands case-sensitive?
Yes
What is the Linux command that reports its function and syntax?
–help
How is the command “–help|more” different from “–help”?
–help|more shows the results a page at a time while –help shows all the results at once
What is the most common text editor?
Nano is a command-line text editor operated by CTRL key combinations.
What do these CTRL+ key shortcuts mean: CTRL+O and CTRL+X?
CTRL+O writes changes to the file and CTRL+X quits the editor
What are the two modes for vi or vim?
Vi is a command-line text editor that extends the original vi software. Vim uses a command mode for file operations and an insert mode for editing.
What do these commands in vim command mode mean:
:set number
:w
:wq
:q!
:set number is to show line numbers
:w is to save a file
:wq is to save and quit
:q! is to quit without saving
In a Linux system, what specifies how the directories under root should be named and where types of files should be placed?
Linux file system hierarchy standard (FHS)
What are the core commands to navigate the Linux file system?
pwd
cd
ls
cat
What is the function of this Linux command: pwd?
pwd shows the current directory (print working directory). The working directory is important because any commands you use which don’t specify a path as an argument will default to the working directory
What is the function of this Linux command: cd?
cd (Change Directory) is used to change the working directory.
- Change directory to /etc. This is an absolute path from root (begins with /) so will work regardless of your current directory: cd /etc
- Change your directory to a subdirectory “documents”. This is a relative path because “documents” must exist below the current directory: cd documents
- Chang your directory to the parent directory of the one you are currently working in: cd ..
What is the function of this Linux command: ls?
ls is for listing file system objects.
-l is used to display a detailed list
-a is used to display all files including hidden or system files.
What is the Linux system command path to show the entire contents of the /etc directory in a detailed format?
ls -la /etc
What is the function of this Linux command: cat?
cat is used to view and combine (concatenate) files. The -n switch adds line numbers to the output. cat output is piped to a pager (cat | more or cat | less) to control scrolling.
cat > file is used to overwrite any data at the destination file.
cat»_space; file is used to append the cat data to the destination file.
What is the function of this Linux command: find?
The find command is used to search for files. The basic syntax is “find path expression”, where ‘path’ is the directory in which to start the search and ‘expression’ is the data to match.
What is the function of this Linux command: grep?
The grep (Globally search a Regular Expression and Print) command is used to search and filter the contents of files.
What is the function of this Linux command: cp?
cp is used to create a copy of files.
- Copy ‘file1.txt’ in the current working directory to a new file called ‘file1.old’ in the same directory: ‘cp file1.txt file1.old’
- Copy the file hosts from the directory ‘/etc’ into the directory ‘/tmp’, keep the file name the same: ‘cp /etc/hosts /tmp’
- Copy all files beginning with the name message from the ‘/var/log’ directory into ‘/home/david’. The ‘-v’ option displays the files copied: ‘cp -v /var/log/message* /home/david’
What is the function of this Linux command: mv?
The mv command is used to either move files from one directory to another or rename a file.
- Move the file ‘data.txt’ from the ‘/home/david’ directory to the ‘/tmp’ directory, keeping the file name the same: ‘mv /home/david/data.txt /tmp’
- Move and rename the file ‘alarm.dat’ in the current directory to ‘alarm.bak’ in ‘/tmp’: ‘mv alarm.dat /tmp/alarm.bak’
- Rename the file ‘app1.dat’ in the ‘.var/log’ folder to ‘app1.old’: ‘mv /var/log/app1.dat /var/log/app1.old’
What is the function of this Linux command: rm?
The rm command can be used to delete files. It can also be used with the ‘-r’ option to delete directories.
- Remove the single file ‘data.old’ from the current working directory: ‘rm data.old’
- Remove all files ending in ‘.bak’ from the ‘/var/log’ directory: ‘rm /var/log/*.bak’
- Remove the contents of the entire directory tree underneath the folder ‘/home/david/data’: ‘rm -r /home/david/data’
What is the function of this Linux command: df?
df “disk free” enables you to view the device’s free space, file system, total size, space used, percentage value of space used, and mount point.
What is the function of this Linux command: du?
du “disk usage” displays how a device is used, including the size of directory trees and files within it
What is the term for an administrator account in Linux?
root user or superuser
What is the function of this Linux command: su?
The su (switch user) command switches to the account specified by username: ‘su username’. Using ‘su-‘ changes to the root user and launches a new shell under the context of root
What is the function of this Linux command: sudo?
The sudo (superuser do) command allows any account listed in the ‘/etc/sudoers’ file user to run specified commands with superuser privilege level. The user enters the ‘sudo’ command followed by th command the user wishes to run.
What are the Linux commands to add, modify, and delete user info? And change password?
useradd
usermod
userdel
passwd
What are the Linux commands to manage group memberships?
groupadd
groupmod
groupdel
Linux uses a permissions system with what three rights?
- Read (r) gives permission to view the contents of a file or directory.
- Write (w) gives permission to modify or delete the object. In the case of directories, this allows adding, deleting, or renaming files within the directory.
- Execute (x) gives permission to run an executable file or script. For directories, execute allows the user to do things such as change the focus to the directory and. access or search items within it
What is symbolic notation?
Symbolic notation is syntax for setting Linux permissions that uses characters to represent permissions values. Each permission is allowed (r or w or x) or denied (-).