Linux

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Which command is used to change directories? -Using the same command can you name possible ways to navigate back to your home folder?

* cd (The "Change directory" command is used to change the current location within the command line terminal.) User should name the following * cd (when used on its own it will navigate back to home folder) * cd ~ * cd $HOME

Can you describe the function and use case for any of the following file system tools ? *blkid *chattr *debugfs *dumpe2fs *e2label *resize2fs *tune2fs

blkid - Display information about block devices such as storage devices chattr - Change file attributes on the file system debugfs - manually view and modify the file system structure, such as undeleting a file or extracting a corrupted file. dumpe2fs - Display block and superblock group information e2label - Change the label on the filesystem resize2fs - Expand or shrink a file system tune2fs - Modify filesystem parameters

What is grep, egrep, or fgrep? How would you use grep to find any occurrences of the name Paul in the file members.txt ? How do we use grep to tell us how many occurrences of the name Paul are in the members.txt file ?

GREP searches for specific strings from standard input A couple of examples of how the user could use the grep command: grep paul members.txt or cat members.txt | grep paul The use of "grep -c paul members.txt" would give a count of the times this appears in the file

How do you reboot a Linux box? You want to shutdown the system at 13:00, how would you schedule this from the command line? -How could you create a broadcast to notify the users of the impending shutdown when it happens at 13:00?

ctrl-alt-del, shutdown -r, reboot, init 6 To plan the shutdown for 1pm the easiest would be the following: shutdown 13:00 To broadcast a message you can add it on to the shutdown command e.g.: shutdown 13:00 The system is going down for maintenance

Can you name any Linux Filesystems?

brts - newer high-performance file system. Can perform its own form of RAID as well as Logical Volume Management ecrypytfs- Enterprise Cryptographic Filesystem applies a POSIX(Portable Operating System Interface) compliant encryption protocol to data before storing it on the device. This provides an additional layer of security for data stored on the device. ext3 -supports files up to '2TiB' with a total file system of 16TiB. Supports journaling as well as faster start up and recovery. ext4 - Similar to ext3 except it supports the total file system of 1 EiB and utilizes improved performance features. It is also the current version of the original Linux file system. reiserFS - Created before ext3fs and commonly used on older systems swap - The swap filesystem allows you to create virtual memory for your system using space on your physical disk.

Using the command line which command would display a list of files/folders from the current directory -How would you display the list of files within the ~/Downloads folder without moving from the current directory location ? -How would you also display the permissions associated to the files within the ~/Downloads folder ?

* ls (If a flag is used get the user to explain) * ls ~/Downloads (This is the ideal answer, user may opt to cd to the Downloads folder and run the ls command whilst this would work we asked for the contents without changing the current directory so is wrong) * ls -l ~/Downloads ( The use of the -l flag would provide the file permissions as requested if the -l flag is combined such as -lh ask user to explain more) * useful flags also include -a (all) and -h (human readable file size) ---------------------------------------------------

- What is the command used to create new directory? - Your current location is /etc/var/html folder. Without moving directory how do you create a directory named "test" in the following location ~/Desktop/books How do you remove a file? · How do you remove a file you don't have permissions for? · How do you remove a file called dash r ?

* mkdir (The "Make directory" command creates a directory in the current location) * mkdir ~/Desktop/books/test (This would create the folder at the requested location without the user needing to move to that folder using the cd command" ------------------------------------------------------------- * rm (The remove command will delete a file) * sudo rm (This will enable you to remove any file as root user) * rm "dash r" (The use of quotes will usually help to escape special characters and whitespace) there are other ways too get the user to explain (such as just -r)

What service is used to translate domain names to IP addresses? host - what does this command do? dig - what does this command do ? -How can you use dig to help determine if there is an issue with your dns server?

*DNS - On most Linux operating systems, the DNS servers that the system uses for name resolution are defined in the /etc/resolv.conf file. That file should contain at least one nameserver line. Each nameserver line defines a DNS server. The name servers are prioritized in the order the system finds them in the file *The "host" command queries the DNS server to determine the ip addresses assigned to the specified host name. *The "dig" command queries the DNS server to determine the ip addresses assigned to the specified host name. *The dig command also allows you to specify a different DNS server which is a handy way of determine whether your default DNS server is at fault if a name resolution fails.

What is the difference between Global and Local variables? printenv - What does the output of this command display? Please study the following text: [explain the commands] $ test=testing $ echo $test What would the output be from this command? -what type of environment variable is "$test" Please study the following text [only additional commands needs to be explained if the previous was answered correctly] $ test=testing: $ echo $test testing $ export test $ bash $ echo $test testing Can you explain the process from the output? What function does the "export" command play?

*Global environment variables are visible from the shell session and from any child process the shell spawns. Local environment variables are only available in the shell that creates them. *printenv displays all the current global environment variables *The command would display "testing" *This type of variable is a local variable A local variable "test" is created and given the value of "testing" this is echoed to the terminal. The "export" command is ran against the local variable "test". This converts the local variable to a global variable. The "bash" command spawns a child process. The now Global variable of "test" is echoed to the terminal to prove the export command converted the variable from a local to global variable.

What is sudo and why would you use it? How is sudo different from Su? What is the default sudo configuration file location? How would you add user Paul to the sudoers group using the command line?

*Sudo allows you to run a program as another user such as root. *Sudo is commonly used to allow admin rights to perform tasks that a standard user cannot such as creating folders or running programs that require root permissions. *Su switches you to another user typically root. *Default file location for the primary configuration file is /etc/sudoers * sudo usermod -aG sudo Paul

What does the cat command do? You attempt to run a script but get an error that message that refers to "line 42" which cat command option would help you to identify line 42? What does the head command do? What does the tail command do? - What is the benefit of using the -f switch with the tail command example tail -f /var/log/auth.log

*The cat command displays the contents of a file *The use of the "cat -n" appends each line with a number that would allow easy identification of line 42 *The head command by default displays the first ten text lines of a file. *By default the tail command displays a files last ten text lines of a file. *The -f switch allows to monitor a file as new entries are added. The example in the question refers to a log file which would allow for live monitoring of entries as they happen.

netstat - What does this command do ? -Can you explain any optional switches with this command ss - what does this command do?

*The netstat command provides a wealth of network information. By default it lists all open network connections on the system. netstat -t This displays only tcp connections. netstat -u This displays only udp connections. netstat -l lists which applications are listening on which port. netstat -s displays statistics for the different types of packets the system has used on the network. The ss command can link which system processes are using which network sockets that are currently active.

What does the mount command do? What does the tool mkfs allow us to do? What raw device file would Linux create for the second SCSI drive connected to the system? Which file does Linux use to indicate which drive devices should be mounted to the virtual directory at boot time? -is this the best way to mount a temporary device? -if a device detailed in this file is removed and the file not altered to reference the change what will happen at the next boot up?

*Without any parameters the "mount" command displays all devices currently mounted on the Linux system. It is used also to mount a filesystem to the Linux virtual directory (mount -f fstype device mountpoint) *The mkfs program is actually a front end to several individual tools for creating specific file systems *Linux creates files named sdx in the /dev directory for SCSI devices. For the second SCSI device , Linux would create the file /dev/sdb */etc/fstab - Is referenced by Linux to determine which devices should be mounted at boot time. *No, use the mount command for temporary use of devices, editing the fstab file Is a more long term solution and requires the device to be present at each boot up. *if the device referenced has been removed the system will throw a boot error.

Which command line utility would you use to change the permissions of a file/folder that you own - You own the file "Amazon.sh", how would you make it executable What command you would use to create a symbolic link instead of hard link? How do you delete a symbolic link?

*chmod - is the utility to use when changing permissions *chmod +x Amazon.sh or user may use octal mode e.g. chmod 777 Amazon.sh if that's the case get them to break it down. *ln -s {/path/to/file-name} {link-name} *rm {link-name}

What command is used to remove jobs from the print queue? = lprm If no arguments are supplied with the command what is the default action? How do you cancel a specific job in the queue? What if a specific printer needs to be targeted?

*lprm - lprm cancels print jobs that have been queued for printing. *If no arguments are supplied, the current job on the default destination is cancelled. *You can specify one or more job ID numbers to cancel those jobs or use the - option to cancel all jobs. Example for a specific printer lprm -P lba3-prt-1 all or lprm -P lba3-prt-1 <job ID>

Name some default Linux directories and their uses

/ --> The top level directory in your system. It's called the root directory, because it's the root of the system. /bin --> Binaries. Commands needed during bootup that might be needed by normal users. /boot --> Files used by the bootstrap loader, LILO. Kernel images are often kept here /dev --> Device files for devices such as disk drives, serial ports, etc /etc --> Configuration files specific to the machine. /home --> User's home directories. /lib --> Shared libraries needed by the programs on the root file system. /lost+found --> Recovered Files from system crash that may be corrupt. /media --> Subdirectories where removable media devices inserted into the computer are mounted. /mnt --> Mount points for temporary mounts by the system administrator. /opt --> Optional software that you installed. /proc --> This file system is not on a disk. Exists in the kernels imagination (virtual). This directory Holds information about kernel parameters and system configuration. /root --> The home directory of the root user. /run --> Application State Files /sbin --> Like bin but commands are not intended for normal users. Commands run by LINUX. /srv --> Service Data. Data for services provided by the system. /tmp --> Temporary files. Programs running after bootup should use /var/tmp. Periodically cleaned. /usr --> Contains all commands, libraries, man pages, games and static files for normal operation. /var --> Contains files that change for mail, news, printers log files, man pages, temp files.

What do the following utilities allow you to configure/change? *nmtui *nmcli - what is the difference between the two? - What information do these provide?

Both tools are a part of the "Network manager tool" *nmtui - Provides a simple text based menu tool *nmcli - Provides a text-only command-line tool Both tools help guide you through the process of setting the required information for your system. The nmcli in comparison to the nmtui doesn't attempt to use any type of graphics capabilities. By default the command displays the current network devices and their settings.

What does the command split do? -Can you explain the following: You have a file named fourty.txt that contains forty lines of text, How would you use the split command to split the file into four separate files appended "split40" ? What does the command sort command do? Which argument used with sort would be used to sort contents of a file in numerical order?

Split allows you to divide a large file into smaller chunks split -l 10 fourty.txt split40 - This would split the main file into four files with ten lines each in them. The files would be named: split40aa split40ab split40ac split40ad *The sort utility sorts a files data, it doesn't alter the files content just the output *Using sort with the -n argument will order the content in numerical order

Which redirection operator allows you to redirect STDOUT, STDIN and STDERR between multiple commands all on one command line ? By default where does STDOUT direct output to ? By default how does STDIN come into your Linux system? Can you name any redirection operators and their description?

The Pipe command allows for simple redirection between commands By default STDOUT directs output to the current terminal By default STDIN comes into the system via the keyboard and/or other input devices. > Redirect STDOUT to a specified file, if file exists overwrite it if it does not exist, create it. >> Redirect STDOUT to specified file, if the file exists append it. If it doesn't exist create it. 2>Redirect STDERR to specified file, if the file exists overwrite it. If it does not exist create it. 2>>Redirect STDERR to specified file. If the file exists, append to it. If it does not exist create it. &> Redirect STDOUT and STDERR to specified file. If file exists overwrite it. If it doesn't exist create it. &>> Redirect STDOUT and STDERR to a specified file. If the file exists append to it. If it doesn't exist create it. < Redirect STDIN from specified file into command <> Redirect STDIN from specified file into command and redirect STDOUT to specified file. 2>&1 redirect STDERR to SDOUT

How many command line commands do you know that allow you to display the name of the server you are on from command line?

The answer should mention one of the following: * uname -a or uname -n * hostname or hostnamectl * cat /etc/hostname * cat /proc/sys/kernel/hostname --------------------------------------------------

After looking at the 'history' the terminal displays a number of commands prefixed by 10, 20, 30, 40 and so on. - What shortcut command would rerun the command numbered 20? - How do we rerun command numbered 40 but with elevated privileges? -Can you think of any other shortcuts to rerun previous commands and maybe some use cases ?

The answer should mention one of the following: * !20 (this would run the command again) or user may state they could press the "up" key till they reach that command (not really what we are looking for) * sudo !! OR sudo !40 can be used ideally. User may say press the "up" key and add sudo (again not really what looking for) ----------------------------------------------------

Can you think of any commands that will display recently executed commands from the current logged in session? If you can think of multiple can you explain them and provide any use cases?

The answer should mention the following * The "history" command, this would provide a list of previously ran commands. * The User may mention the contents of the /.bash_history file but this would not display any commands from the current logged in session. --------------------------------------------------

Linux uses a three tiered approach to protecting files and directories Can you name these them ? You issue a "ls -l" command and get the following output : -rwxrw-r 1 John sales 479 Jan 19 15:37 reserach.txt Can you explain the permissions this file has allocated ? What command can be used to change the owner of this file? What command can be used to change the files group ownership?

The three tiers are: -Owner: Each file and directory is assigned to a single owner -Group: The files and directories are assigned to a single group of users, this group can be assigned specific privileges to the file or directory that differ from the owner privileges. -Others: This category is permissions assigned to accounts that are neither the file owner nor the assigned user group. The file has the following permissions set: -First column (Owner) has read write and execute permissions -Second Column (Group) has read and write permissions. -Third Column (Others) has read only. Owner is John, Group is sales chown - The command chown, an abbreviation of change owner, is used on Unix and Unix-like operating systems to change the owner of file system files, directories. chgrp - The command chgrp, an abbreviation of change group is used to change the group ownership on the file.

Can you the use of the following tools in helping you to monitor disk performance and usage? *df *du *iostat *lsblk

df - Displays disk usage by partition du - Displays disk usage by directory ; good for finding users or applications that are taking up the most space iostat - Displays real-time chart of disk statistics by partition lsblk - Displays current partition sizes and mount points

Network 003 Legacy tools such as the net-tools package contain the following tools *ethtool *ifconfig *iwconfig *route Are you able to explain any of these tools and their functions

ethtool - Displays Ethernet settings for a network interface ifconfig - Displays or sets the IP address and netmask values for a network interface iwconfig - Sets the SSID and encryption key for a wireless interface route - Sets the default router address


Kaugnay na mga set ng pag-aaral

Chapter 24: Assessment of the Respiratory System

View Set

REHAB 544 Exam 3 Clinical Correlations

View Set

ATI: Adult Medical Surgical Gastrointestinal

View Set

Section 2. Chapter 11: Using Preventive Agents

View Set

Chain of infection/ Infection control measures- unit test

View Set

Med surge NCLEX questions- respiratory

View Set