Linux Midterm - Ch 1-26

Bash

Definition - The shell program that all Linux distributions supply from the GNU Project. This is a reference to the fact that this is an enhanced replacement for sh, which was the original Unix shell program written by Steve Bourne. But don't get that con

What does the Bash acronym mean?

Acronym - Bourne Again Shell

pwd

Command - Print name of current working directory

cd

Command - Change directory

ls

Command - List directory contents

The Current Working Directory

Definition - A file manager which represnts the file system tree. When your in a file, you can access other files in the directory above (also called the parent directory) and any subdirectories below. The directory your currently in is this thing. To dis

pwd example

example - [me@linuxbox ~]$ pwd
/home/me

ls example

example - [me@linuxbox ~]$ ls

cd example

example - [me@linuxbox ~]$ cd /usr/bin

Relative Pathnames

Definition - This starts from the working directory. To do this, it uses a couple of special notations to represent relative positions in the file system tree. These special notations are
"." (dot) and ".." (dot dot).
The "." notation refers to the workin

Examples of using ls Command

Example - [me@linuxbox ~]$ ls
Desktop Documents Music Pictures Public Templates Videos
Besides the current working directory, we can specify the directory to list, like so:
me@linuxbox ~]$ ls /usr
bin games include lib local sbin share src
We can even spe

Examples of using ls -l Command

example - [me@linuxbox ~]$ ls -l
total 56
drwxrwxr-x 2 me me 4096 2017-10-26 17:20 Desktop
drwxrwxr-x 2 me me 4096 2017-10-26 17:20 Documents
drwxrwxr-x 2 me me 4096 2017-10-26 17:20 Music
drwxrwxr-x 2 me me 4096 2017-10-26 17:20 Pictures
drwxrwxr-x 2 me

Examples of using ls -lt Command

example - [me@linuxbox ~]$ ls -lt
This command is given two options, which are the l option to produce long format output,
and the t option to sort the result by the file's modification time.

Examples of using ls -lt --reverse Command

example - [me@linuxbox ~]$ ls -lt --reverse
This command is given two options, which are the l option to produce long format output,
and the t option to sort the result by the file's modification time then adding the last option will reverse the entire ou

ls -a --all

option - This option is used with the ls command - it means List all files, even those with names that begin with a period, which are normally not listed (that is, hidden).

ls-a --almost-all

option - This option is used with the ls command - it means Like the -a option above except it does not list . (current directory) and .. (parent directory).

ls -d --directory

option - This option is used with the ls command - it means Ordinarily, if a directory is specified, ls will
list the contents of the directory, not the directory itself. Use this option in conjunction
with the -l option to see details about the directory

ls -F --classify

option - This option is used with the ls command - it means This option will append an indicator character
to the end of each listed name. For example, a forward slash (/) if the name is a directory.

ls -h --human-readable

option - This option is used with the ls command - it means In long format listings,
display file sizes in human readable format rather than in bytes.

ls -l

option - This option is used with the ls command - it means to Display results in long format.

ls -r --reverse

option - This option is used with the ls command - it means Display the results in reverse order. Normally,
ls displays its results in ascending alphabetical order.

ls -S

option - This option is used with the ls command - it means Sort results by file size.

ls -t

option - This option is used with the ls command - it means Sort by modification time.

ls Long Listing Fields Examples

example - Using ls Long Listing fields Example
-rw-r--r-- 1 root root 3576296 2017-04-03 11:05 Experience ubuntu.ogg
-rw-r--r-- 1 root root 1186219 2017-04-03 11:05 kubuntu-leaflet.png
-rw-r--r-- 1 root root 47584 2017-04-03 11:05 logo-Edubuntu.png
-rw-r-

CNTRL h

Command - Display help screen

/etc

Directory - The /etc directory contains all of the system-wide
configuration files. It also contains a collection of shell
scripts that start each of the system services at boot time.
Everything in this directory should be readable text.
Interesting files

/mnt

Directory - On older Linux systems, the /mnt directory contains mount
points for removable devices that have been mounted
manually.

Symbolic Link example

example - lrwxrwxrwx 1 root root 11 2007-08-11 07:34 libc.so.6 -> libc-2.6.so

Hard Links

DEFINITION - allow files to have multiple names
1. A hard link cannot reference a file outside its own file system. This means a link
cannot reference a file that is not on the same disk partition as the link itself.
2. A hard link may not reference a dir

cp

Command - Copy files and directories

mv

Command - Move/rename files and directories

mkdir

Command - Create directories

rm

Command - Remove files and directories

ln

Command - Create hard and symbolic links

* Key

Wildcard - Matches any characters / or All files

? Key

Wildcard - Matches any single character

cp item 1 item2

Wildcard Example - copies the single file or directory item1 to the file or directory item

cp item...directory

Wildcard Example - copies multiple items (either files or directories) into a directory

cp -a

cp option - "--archive - Copy the files and directories and all of their attributes, including ownerships and permissions.

cp -I

cp option - "--interactive - Before overwriting an existing file, prompt the user for confirmation.

cp -r

cp option - "--recursive - Recursively Copy directories and their contents.

cp -u

cp option - ""--update - When copying files from one directory to another,
only copy files that either don't exist or are newer than the existing corresponding files,
in the destination directory. This is useful when copying large numbers of files as it s

cp -v

cp option - "--verbose - Display informative messages as the Copy is performed.

cp file1 file2

cp example - Copy file1 to file2. If file2 exists, it is overwritten with the contents of file1. If file2 does not exist, it is created

cp -i file1 file2

cp example - Copy file1 to file2 and file2 exists, the user is prompted before it is overwritten.

cp file1 file2 dir1

cp example - Copy file1 and file2 into directory dir1. The directory dir1 must already exist.

cp dir1/* dir2

cp example - Using a wildcard, copy all the files in dir1 into dir2. The directory dir2 must already exist.

cp -r dir1 dir2

cp example - Copy the contents of directory dir1 to directory dir2. If directory dir2 does not exist, it is created and, after the copy, will contain the same contents as directory dir1. If directory dir2 does exist, then directory dir1 (and its contents)

mv item1 item2

mv option - move or rename the file or directory item1 to item2

mv item... directory

mv option - move one or more items from one directory to another

mv -i

mv option - "--interactive - Before overwriting an existing file, prompt the user for confirmation. If this option is not specified, mv will silently overwrite files.

mv -u

mv option - "--update - When moving files from one directory to another, only move files that either don't exist, or are newer than the existing corresponding files in the destination directory.

mv -v

mv option - "--verbose - Display informative messages as the move is performed.

mv file1 file2

mv example - Move file1 to file2. If file2 exists, it is overwritten with the contents of file1. If file2 does not exist, it is created. In either case, file1 ceases to exist.

mv -i file1 file2

mv example - Same as the previous command, except that if file2 exists, the user is prompted before it is overwritten.

mv file1 file2 dir1

mv example - Move file1 and file2 into directory dir1. The directory dir1 must already exist.

mv dir1 dir2

mv example - If directory dir2 does not exist, create directory dir2 and move the contents of directory dir1 into dir2 and delete directory dir1. If directory dir2 does exist, move directory dir1 (and its contents) into directory dir2.

rm item...

rm option - used to remove (delete) files and directories

rm -i

rm example - "--interactive - Before deleting an existing file, prompt the user Before deleting an existing file, prompt the user for confirmation. If this option is not specified, this will silently delete files.

rm -r

rm example - ""--recursive - Recursively delete directories. This means that if
a directory being deleted has subdirectories, delete them too. To delete a directory, this option must be specified.

rm -f

rm example - "--force - Ignore nonexistent files and do not prompt. This overrides the --interactive option.

rm -v

rm example - "--verbose - Display informative messages as the deletion is performed.

rm file1

rm example - Delete file1 silently.

rm -i file1

rm example - Same as the previous command, except that the user is prompted for confirmation before the deletion is performed.

rm -r file1 dir1

rm example - Delete file1 and dir1 and its contents.

rm -rf file1 dir1

rm example - Same as the previous command, except that if either file1 or dir1 do not exist, rm will continue silently.

rm *.html

rm example - delete just the HTML files in a directory

ln file link

ln command - creates a hard link

ln -s item link

ln command - creates a symbolic link

inode

DEFINITION - this contains the description of the file

(') Single quotes

key - these allow you to use spaces in your code

<

Redirect - stdin so that input to command comes from a file (instead of keyboard)

>

Redirect - stdout so that output from command goes to a file (instead of console)

>>

Redirect - stdout so that output is appended to a file

|

key - piping - also known as a double redirection

cat

COMMAND - this catenates files and prints out all the contents on the screen

echo

COMMAND - used to display a string on the screen

uniq

COMMAND - operates on consecutie, duplicate lines of text

grep

COMMAND - search for lines matching an expression

alias

COMMAND - a shortcut to simplify a long winded command

cut

COMMAND - this grabs a file so you can paste it

File Descriptors

DEFINITION - also known as Drivers. The POSIX standard defines this per-process unique, non negative integer used to identify an open file for the pruposes of file access. It does not describe a file, it just is a number that is ephemerally associated wit

Who created the first so-called Linux?

The history of Linux - Linus Torvalds in 1991

Linux is created based on what?

The history of Linux - The Linux kernel, based on UNIX, was developed in the early 1990s by Linus Torvalds. By 1991, Torvalds had released the first version � just 10,000 lines of code � and sparked excitement in the software development community with th

format of passwd file

COMMAND - The format of the passwd file is a text file. You can find out more information on this file under the passwd man page. You use the passwd command when you want to set or change your password. You can only change other users passwords if you hav

ls with wildcard ?

COMMAND - The ls command is used to list a directories contents.
The wildcards (also known as globbing) which allows us to select filenames based on patterns of characters.
The wildcard "" ? "" used with the ls command matches any single character (but no

ls with wildcard *

COMMAND - The ls command is used to list a directories contents.
The wildcards (also known as globbing) which allows us to select filenames based on patterns of characters.
The wildcard "" * "" used with the ls command matches any string of characters [in

sudoer file and its format

COMMAND - This stands for ""Super User Do"" which allows you to run programs as another user, by default the root user. If you spend a lot of time on the command line, sudo is one of the commands that you will use quite frequently.
Using sudo instead of l

sudoer file and how to edit it

COMMAND - You can edit a sudoer by use of "visudo

sudoer file and how to edit its permission

COMMAND - You can list the set of privileges that are granted by sudo by using the "" -l "" option to list them.
Ex.
[me@linuxbox ~]$ sudo -l =>
User me may run the following commands on this host:
(ALL) ALL
To change permissions using sudo, you can use t

pipe

COMMAND - This command pipes the output of the previous command to the next command.

file commands

Command - These are some of the commands that are used with files:
ls - List directory contents (use ls -l wildcard or others to filter your findings)
file - Determine file type (determines a files contents)
less - View file contents per single page.
cp -

directory commands

command - These are some of the commands that are used with directories:
cp - Copies files and directories
mkdir - Makes a new directory
mv - Moves/renames files and directories
rm - Removes files and directories

Hard link

Link - Hard links point to the targets file's iNode.
You can create a hard link by using "" -ln ""
Notes about a Hard link:
� Very simple to have two filenames, in the same or different directories, that
point to the same inode
� This is why both of the f

Symbolic Link

Link - Symbolic links point to the file itself.
You can create a symbolic link by using "" ln -s ""
Notes about a Symbolic links:
� One filename points to another filename
� Works across filesystems
� To create softlinks use ln -s
� A Symbolic Link is an

Can a Hard link work across a file system? Why?

File and directory commands - No, a hard link can not work across a file system.
Hard links have two important limitations:
1. A hard link cannot reference a file outside its own file system. This means a link
cannot reference a file that is not on the sa

Can a Symbolic link work across a file system? Why?

Can this work? - Yes, a symbolic link can link across file systems and directories or even across machines.
Symbolic links were created to overcome the limitations of hard links. They are a special type of file that contains a text pointer to the target f

rwx representation

File Permission - File permissions: File attributes contain Read, Write, and Execute (r,w,and
x) permission bits for each type of user access:
� (1) User owner
� (2) Group owner -- users who are members of the owning group
� (3) Other (aka World) -- users

octal number presentation

File Permission - With octal notation, we use octal numbers to set the pattern of desired permissions. Since
each digit in an octal number represents three binary digits, this maps nicely to the scheme used to store the file mode
� Octal digit: base-8 num

how does rwx work on files?

How does this work? - When dealing with files, the permissions for their directories is important. Here is what can be set to read, write, or execute a file in a directory.
� R - permission to read the directory (see details about the files in the
directo

how does rwx on directories?

How does this look? - When dealing with directories, the permissions for these directories is important. Here is what can be set to use, view, or create a directory. Same principles as a file permission.
� R - permission to read the directory (see details

What is unmask?

What is? - umask : Shell built-in command used to set default permissions for files
created by user
� When umask is expressed with symbols, the settings represent which
permissions are granted
� Same as chmod
� When umask expressed numerically, the bits r

What is unmasks conversion to octal number permission for files and directories?

What is? - The umask command controls the default permissions given to a file when it is created.
It uses octal notation to express a mask of bits to be removed from a file's mode attributes.
Ex.
[me@linuxbox ~]$ rm -f foo.txt
[me@linuxbox ~]$ umask
0002

sticky bit

File Permission - This is a holdover from ancientUnix, where it was possible to mark an executable file as "not swappable."
On files, Linux ignores the sticky bit, but if applied to a directory, it prevents users
from deleting or renaming files unless the

What is a setuid bit and what does it mean?

What is? - This is always applied to executable files
� Processes that execute this kind of file: are given an effective UID
whose value is the UID of the file owner
� Granting access to resources based on the user owner of the file rather than
the owner

What is a setgid bit and what does it mean?

What is? - This is very similar to setuid
� GID instead of UID
� When applied to directory
� Newly created files in the directory have the same group owner as
the directory's group owner
Known as Octal 2000.
Like the setuid bit, it changes the effective g

Variable

Environmental variable - A variable is a storage location (identified by a memory address) paired with an associated symbolic name (an
identifier), which contains some known or unknown quantity of information referred to as a value.
� The variable name is

Environment variable

Environment - The shell stores two basic types of data in the environment; though, with bash, the
types are largely indistinguishable. They are environment variables and shell variables.
Shell variables are bits of data placed there by bash, and environme

export

Environmental variable - The export command is used when defining an environmental variable. You first have to define the environmental variables name and value (assignment/set), then exporting it with the export command
*export - Export environment to su

$PATH

Environmental variable - PATH is an environmental variable in Linux and other Unix-like operating systems that tells the shell which directories to search for executable files (i.e., ready-to-run programs) in response to commands issued by a user.

What does a double quote do in an environment?

What does this do? - The first type of quoting we will look at is double quotes. If we place text inside double
quotes, all the special characters used by the shell lose their special meaning and are
treated as ordinary characters. The exceptions are $, \

What does a single quote do in an environment?

What does this do? - If we need to suppress all expansions, we use single quotes. Here is a comparison of unquoted, double quotes, and single quotes:
[me@linuxbox ~]$ echo text ~/*.txt {a,b} $(echo foo) $((2+2)) $USER
text /home/me/ls-output.txt a b foo 4

PWD mean when used with echo (Ex. Echo$(PWD))

What does this mean? - This usage of $PWD prints the current working directory
Examples of PWD to disquish correct use vs. incorrect use (note the difference)
$echo PWD => PWD (incorrect)
$echo $PWD => /home/ruizhao (correct)

What does $pwd mean when used with echo (Ex. Echo$(pwd))

What does this mean? - This usage of $pwd prints nothing. This is because the Value of unassigned shell variable is empty string. This is an incorrect attempt to use the $PWD (print working directory. Use $echo $PWD instead)
Examples of pwd:
$echo pwd =>

What is bashrc?

What is? - This is an important Startup file for Non-Login shell sessions. This file is a users personal startup file. It can be used to extend or override setting in the global configuration script. This being on the more important startup files because

What is bash_profile?

What is? - This bash_profile file is where you can add directories to your PATH or define additional environmental variables. Everything else is done in bashrc.
Additional lecture slides:
During the login scripts, The "bash" shell will look for login scri

What is a process?

What is? - A process is sometime referred as task.
� A process has its own address space.
A Job or Command may consist of several processes working together to perform a single task
� Process: Single executable running in own address space
� A process may

What is a pid?

What is? - PID stands for process ID. It is a numeric id assigned to each process that is given to track each process. The external PS commands track the processes by JOB_SPEC. When killing a process, you refer to this number so specify what to kill.
Exam

How do you show all the processes on the machine (2 ways)?

How do you? - Using the ps search command with the "" x "" option shows all of our processes regardless of what terminal (if any) they are controlled by.
Example:
[me@linuxbox ~]$ ps x
PID TTY STAT TIME COMMAND
2799 ? Ssl 0:00 /usr/libexec/bonobo-activati

How do you put a process run on background (2 ways)?

How do you? - To launch a program so that it is immediately placed in the background, we follow the command with an ampersand (&) character.
[me@linuxbox ~]$ xlogo &
[1] 28236
[me@linuxbox ~]$
After entering the command, the xlogo window appeared and the

How do you kill a process?

How do you? - The kill command will send the signals to the desired process
� Can send them by abbreviated name
� -HUP
� -USR1
� -INT
� Can send them by number
� -1
� -9
� -15
� The most nasty killer
� kill -9 pid
� Signal 9 is SIGKILL
� Eliminates the pr

What is a processes parent processes?

What is? - The boot process starts a single process which is the parent process. Then from the parrent, other processes can be spawned (called forking) creating new parent processes or children processes. Each time a new process is created, each process g

What is ppid?

What is? - In addition to a unique process ID, each process is assigned a parent process ID (PPID) that tells which process started it.
The PPID is the PID of the process's parent.
For example, if process1 with a PID of 101 starts a process named process2

How do you search for a process?

How do you search? - By using the "jobs" command, you can see a list of all active job processes

How do you use ps with grep?

How do you use? - You can use the external command " ps " and " grep " to run a report of job processes by PID, not by jobs.
Example:
� ps -ef
� ps -ef | grep apache
(This code will show the following)
top - 16:21:20 up 1:06, 40 users, load average: 4.54,

Fstab

Command - The file named /etc/fstab (short for "file system table") lists the devices (typically hard disk partitions) that are to be mounted at boot time.
Here is an example /etc/ fstab file from an early Fedora system:
LABEL=/12 / ext4 defaults 1 1
LABE

df

Command - Using the " df " command, it will allow you to see the current amount of free space on our disk drives.

format of passwd

What is the format? - The passwd format is a text file. Without proper permissions, it cant be accessed.

format of shadow file

What is the format? - The shodow format is a text file. Without proper permissions, it cant be accessed.

fdisk

Command - The fdisk is used to create one or more partitions to a disk drive.
Danger Will Robinson!
� We will use fdisk to create partitions on the drives
� It is destructive (to the whole drive, pretty much)
� So as usual, BE CAREFUL!!!
� Let's pretend w

mkfs

File System Command - You use mkfs to create a new file system on our flash drive.
To do this, we will use mkfs (short for "make file system"), which can create file systems in a variety of formats.
To create an ext4 file system on the device, we use the

mount

File System Command - The mount command allows you to mount a file system onto a storage container.
The first step in managing a storage device is attaching the device to the file system tree.
This process, called mounting, allows the device to interact w

unmount

Command - The unmount command allows you to unmount or ""detach"" filesystems from your device, making the files on the device.
Example:
mount /dev/sdc1 /home/userX @mounts the device sdc1
unmount / dev/sdc1 @unmounts the device sdc1

What are the steps to making a 2nd or new hard drive that is usable to Ubantu?

What are the steps? - Assuming that a new hard drive is connected to the physical or virtual machine, you will need to use fdisk, mkfs, and mount with certain options to do this.

ps

Command - The ps command is used to report a snapshot of the current process.
The most commonly used command to view processes (there are several) is ps. The ps
program has a lot of options, but in its simplest form it is used like this:
[me@linuxbox ~]$

adduser

Command - In Ubantu, you can create a new user account named username using the adduser command you would run:

update

Command - Using the update command, you can update the packages in Debian.
Example:
apt-get update
This will update my list of available packages

upgrade

Command - Using the upgrade command, you can upgrade all your extisting packages to the latest versions in Debian.
Example:
apt-get upgrade
This will update my list of available packages

install

Command - Using the update command, you can install the latest for everything available.

remove

Command - Using the remove command, you can remove the specified package from the machine.
Example:
apt-get remove vim
Vim is the package that will be removed from the machine.

find

Command - The find command is used to "depth-first" search in a file system.
Slide notes:
General usage:
find <options> <directories> <expression> <action>
� <directories> : one or more directories
(and subdirectories) to search
� <expression> : matching

locate

Command - The locate command searches database for any files, anywhere, that match the search
� Uses a prebuilt (or builds it) file database
� Expect a lot of matches
� Usage: locate <options> <pattern>
� In past semesters, the version of Linux we were us

Whats the difference between locate and find?

What is the difference? - Locate uses a prebuilt database, which should be regularly updated, while find iterates over a filesystem to locate files. Thus, locate is much faster than find , but can be inaccurate if the database -can be seen as a cache- is

What is extended regular expression

What is this command for? - The Extended Regular Expressions or ERE flavor standardizes a flavor similar to the one used by the UNIX egrep command. "Extended" is relative to the original UNIX grep, which only had bracket expressions, dot, caret, dollar an

What is a file archive command?

What is this command for? - The Linux 'tar' stands for tape archive, is used to create Archive and extract the Archive files. tar command in Linux is one of the important command which provides archiving functionality in Linux. We can use Linux tar comman

What is a compression command?

What is this command for? - compress command is used to reduce the file size. After compression, the file will be available with an added . Z extension. File permissions will still remain the same as before using compress command.

tar

tar" stands for tape archive, which is used by large number of Linux/Unix system administrators to deal with tape drives backup. The tar command used to rip a collection of files and directories into highly compressed archive file commonly called tarball

QUIZ 1

...

Which of the following statements is wrong?
A. ln "command1; command2", if the execution of "command1" is unsuccessful, the "command2" will be executed.
B. ln "command1 && command2", if the execution of "command1" is unsuccessful, the "command2" will be e

Which one is wrong? - Choice B is incorrect.
In this coding, using the &&, both commands must execute to make this work properly.

In my current directory, there is no file or subdirectory named "my_item", what is the result of executing command "ls my_item | wc -l"?
A. ls: cannot access my_item: No such file or directory 0
B. 1
C. 2
D. 3

What is the result? - Choice A is is the result.
In this coding, since there is no subdirectory named "my_item", it will tell us that the ls command cannot access that file because no such directory exists. They word count (wc) will show zero words.

Which of the following statements is wrong?
A. Hard links can be created across file systems.
B. Symbolic links can be created across file systems.
C. Hard links can be created for files only.
D. Symbolic links can be created among file/directory names on

Which one is wrong? - Choice A is incorrect.
Hard links can not be created across file systems.

Which of the following statements is wrong?
A. "> tmp" will redirect standard output to a file "tmp" and overwrite the file content.
B. ">> tmp" will redirect standard output to a file "tmp" in an append mode.
C. "> tmp 2>&1" will redirect standard output

Which one is wrong? - Choice D is incorrect.
In this coding, putting the ""tmp"" in the incorrect location will not work. It must go in the beginning, not after.

Which of the following statements about the wildcard is wrong?
A. "*" is used to match any string in arbitrary length.
B. "?" is used to match any single character.
C. "[]" is used to match any single character from a set of characters.
D. "[!]" is used t

Which wild card is wrong? - Choice D is an incorrect way to use a wildcard.
In this coding, using the explaination point in the square brackets will not work properly.

To create a symbolic link, in the path of "./shortcut", for file "/home/steal/passwd", what command should we use?

What command should be used? - The correct coding to use is:
ln -s /home/steal/passwd ./shortcut

To create an alias, named "foo", for the commands of "cd /usr; ls; cd ~", what command we should use?

What command should be used? - The correct coding to use is:
alias foo='cd /usr; ls; cd ~'

Hard links link file names and _____.

What does this do? - This will link file names and inodes

Write a wildcard to match all the file names that start with neither character "a" nor character "c" and end with any single character then ".d".

Write code. - [!ac]*?.d

The file descriptor for standard input is _____.
The file descriptor for standard output is _____.
The file descriptor for standard error is _____.

What is the standard input? - The file descriptor for standard input is 0.
The file descriptor for standard output is 1.
The file descriptor for standard error is 2.

QUIZ 2

...

Which of the following commands can print out the full pathname of the current working directory?
A. echo PWD
B. echo ${PWD}
C. echo pwd
D. echo $pwd

Which prints out this? -
Choice B is correct.
Using echo in this way will print out the full pathname of the current directory.

Which of the following commands can NOT print out the hostname?
A. echo $HOSTNAME
B. echo ${HOSTNAME}
C. echo hostname
D. echo $(hostname)

Which does not print? -
Choice C is will not print out the hostname. You must use the $ symbol to have it work properly.

Which of the following info is NOT in the inodes?
A. File type
B. File name
C. Disk address
D. File permission

Which one is not included? - Choice B is not included in the inodes.

File "f.txt" belongs to a user named "steal" and a group named "steal", it has the permission bits of "rwxr-xr--", which of the following statements is wrong?
A. "f.txt" can be written by user "steal"
B. "f.txt" can be written by users in group "steal"
C.

Which statement is wrong? - Choice B statement is incorrect.
Using f.txt can not be written by the users in this group because the permissions are not set properly for the user group. These permissions in this question do not give the group the permission

Which command is used to modify the file/directory permission?
A. ln
B. ps
C. chmod
D. cut

Which command is used to modify? - Choice C command is used to modify the file/directory permission.

Which of the following structure can represent all the processes and their relations in the Linux?
A. linkedlist
B. array
C. tree
D. map

Which structure can represent all the processes and relations? - Choice C structure can represent all the processes and their relations in Linux.

Which is the right symbol that can put the execution of a command to the background?
A. !
B. ^
C. *
D. &

Which is the right symbol? - Choice D is the right symbol that can put the execution of a command to the background.

Write a complete command to define a variable called "foo" with a value of "echo ls > ./foo.txt".

Write a command. - foo='echo ls > ./foo.txt'

Please translate the permission of "753" into rwx representation.

Translate the permission. - rwxr-x-wx

Write a complete command to kill (I really mean to kill) the process whose pid is 3390.

Write a command. - kill -9 3390

QUIZ 3

...

Which command can be used for print out all environment variables?
A. ls
B. cut
C. env
D. Export

Which command can be used? - Choice C command can be used for print out all environment variables.

Which is the correct way to add our own directories to the PATH environment variable?
A. PATH=/home/steal/bin:${PATH}
B. PATH=$(PATH):/home/steal/bin
C. PATH=/home/steal/bin:$(PATH)
D. PATH=${PATH}:/home/steal/bin

Which is the correct way to add our own directories? - Choice D is the correct way to add our own directories to the PATH environment variable.

Which is the correct way to source the script?
A. ./bash_script
B. . ./bash_script
C. > ./bashscript
D. ./bashscript &

Which is the correct way? - Choice B is the correct way to source the script.

The PID of the current bash is 12496.
We have an executable scripted called "pid.sh", which has the following content:#!/bin/bashecho $$
What will be printed out when we "source ./pid.sh"?
A. 29656
B. 1
C. 12496
D. Who knows!

What will be printed? -
Choice C will be printed out when we use "source ./pid.sh".

Which of the following vi commands can be used to save the content on screen and then exit the vi?
A. :q
B. :q!
C. :x
D. :w

Which can be used? -
Choice C can be used to save the content on screen and then exit the vi.

Which command is used to install a package called "java" on Ubuntu?
A. sudo apt-get update java
B. sudo apt-get upgrade java
C. sudo apt-get install java
D. sudo apt-get remove java

Which command is used? - Choice C command can be used to install a package called "java" on Ubuntu.

Which of the following statements regarding the hard drive is correct?
A. SSD has a longer lifetime than disk drive.
B. The hard drive cables have the limited length because we want to ensure the signal quality while the signal transmitted on the cable wi

Which statement is correct? - Choice B statement is correct regarding the hard drive.

How many processes will be forked from process of bash when we run the following script in the bash?
#!/bin/bash
while true
do
sleep 2
date > /dev/null
done
A. 1
B. 2
C. 3
D. 4

How many processes will be forked? -
Choice C is the correct answer. There is a total of 3 processes that will be forked: The bash script is the first fork.The sleep is the the next fork.Then date is the last one.

User "A" own an executable file called "steal.sh". The setuid bit is turned on for this file. This user also grants user "B" the execution permission on his file. When "B" run this file from his bash, there will be a process forked from "B"'s bash process

Who is the owner? - Choice A is the owner of the process corresponding to this file.

QUIZ 4

...

The "find" command implements the _____ algorithm regarding searching tree data structures.
A. breadth-first search
B. depth-first search
C. greedy best first search
D. Who knows!

Fill in the blank. - Choice B algorithm is implemented by the "find" command regarding searching tree data structure.

Which of the following statement is correct for searching out files which have "setuid" bit on?
A. find / -type f \( -perm -2000 \)
B. find / -type f \( -perm -4000 \)
C. find / -type f \( -perm 2000 \)
D. find / -type f \( -perm 4000 \)

Which statement is correct? - Choice B statement is correct for searching out files which have the ""setuid"" bit on. NOTE: THERE IS A DASH BEFORE THE PERMISSION NUMBER

Which command cannot be used for compressing files?
A. gzip
B. gunzip
C. tar
D. bzip2

Which command can't be used? - Choice B can not be used for compressing files.

Which symbol can express the pattern position in regular expression?
A. *
B. .
C. ?
D. $

Which symbol is used? - Choice D is the correct symbol that can be used to express the pattern position in regular expression.

Which text will not be matched by the regular expression 'A.*E'?
A. AE
B. AIRPLANE
C. AIRPLANEDELTA
D. A LONG WAY FROM HERE

Which text will not match? - Choice C text will not be matched by the regular expression 'A.*E'.

Which is the correct regular expression for matching any single digit number?
A. [0123456789]
B. {0123456789}
C. {0-9}
D. [!0-9]

Which is the correct regular expression (RE)? - Choice A is the correct regular expression for matching any single digit number. Note: This one is NOT USING THE SQUIGGLY BRACKETS. So make sure to pick the squared brackets [ ] for this expression.

Which is the correct regular expression for matching the word "book" in both singular and plural forms in the text?
A. 'book'
B. ' book '
C. ' books*'
D. '[[:space:]]books{0,1}[[:space:]]'

Which is the correct regular expression (RE)? - Choice D is the correct regular expression for matching the word "book" in both singular and plural forms in the text.

The regular expression used in the command
grep -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' file
is not able to produce _____ on matching IP addresses in the text?
A. True positive
B. False positive
C. True negative
D. False negative

Which regular expression (RE) is not able to produce? - Choice D is not possible to produce from the text. The other 3 is possible to produce from the text.