Basic Linux Commands( Comptia Objective 1.9) Flashcards

1
Q

In Linux the command prompt utility is called what?

A
  • Terminal or sometimes Xterm or similar.
  • This is similar to the command prompt in Windows.
  • Note Commands are similar in both Linux and macOS. This is because macOS derived from BSD( Berkeley Software Distribution) Unix.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

If you want to see the manual for command line in Linux what command utility can you use to view it?

A
  • “man”. This is an online manual for help using Linux’s command line.
  • If you want to see a manual related to specific commands you would type something like “ man grep” to get a list of commands related to the “ grep” command.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Similar to Windows command prompt command “ dir” Linux also has a command to list the contents of a directory which is?

A
  • ” ls” which stands for list directory contents. Similar to the dir command inn Windows
  • This lists files, directories, may support color coding, Blue is for directory and red is an archive file and white is for a standard file, etc.
  • For Long output with more info use the “ls -l” command and in order to tell the command to stop after 1 page of data before displaying on screen you can also can use the “ | more” to break the info down into pages. Use the command “q” or “ Cntrl-c” to exit
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Just like in Windows you can use this command to change the current directory that you are viewing by typing what?

A
  • “cd” Change current directory.
  • Nearly identiccal to Windows Command line but you use forward slashes instead of backslashes.
  • E.G to view the log directory in Linux you would use the command “ cd /var/log”
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a super useful command that will allow you to search for a specific section of text in a file. Also allowing you to search many files at one time?

A
  • “grep” find text in a file.
  • E.G. to search for the text “ failed” in a specific file you would type “ grep failed [ File name plus file extension]
  • Note the grep command utility is case sensitive so make sure you type the search name by exactly how it would appear.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Because certain actions commands in Linux will require elevated permissions( admin privileges) what command will provide you with those elevated rights?

A
  • ” su” / “ sudo”. Some commands require elevated rights. As there are some things normal users can’t do.
  • “su” command changes the user type to that of a super user. Or allows you to change to a different user. You continue to be that user until you exit the command line using the “exit” command.
  • If you just wish to run a single command as a super user you can use the “sudo” command to execute that one specific command as the super user and than return to the normal user status after that command has been completed.
  • An example of a command that would require elevated permissions of a super user status would be the ability to shut down the system using the “shutdown” command. This allows you to safely turn off the computer in software similar to the Windows shutdown command. So in this instance you would want to type the command “ sudo shutdown” or if you want the system to shutdown after a specified amount of minutes such as 2 minutes you would type “ sudo shutdown 2”
  • If you want to be able to tell the system to shutdown and then reboot after 2 minutes you would type “ sudo shutdown -r 2” to achieve this. This is important to do when you’re not on site.
  • In order to cancel the shutdown process you would have to use one of 2 commands either “ Cntrl-C” or “shutdown -c” depending on the Linux distribution. The command line will state which command to use to cancel the shutdown or reboot process. So full command would either be “ sudo shutdown -c” or “ sudo Contrl-C”
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Because it can sometimes be hard in Linux command line to know exactly what directory you are currently inside of what command utility can you use to find out?

A
  • “pwd” Which means Print Working Directory.
  • Will display the current directory on screen inside of the command line. Displays the current working directory path.
  • This is useful when changing directories often.
    • Note this should not be confused with the command “ passwd” which allows you to change a user account password either yours or another’s. E.G. “ passwd [username]” or simply “ passwd” for your own password.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

If you wanted to move a file or to rename it inside the command line what command would you use to achieve this?

A
  • “mv”. Move a file or Rename a file.
  • For example if you wanted to change the name of a text file called “ soccer.txt” to “football.txt” you would type the following command : “ mv soccer.txt football.txt”
  • To move a file to a different location you would type “ mv “name of file” and then the directory path( E.G /home)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

If you wanted to make a copy of a file or directory what command would you use in Linux to achieve this?

A
  • ” cp” Copy a File. Duplicate files or directories.
  • For an example to copy the text in a file to a new file you would type cp SOURCE DESTINATION. E.G. in order to copy the file “soccer.txt’ to a new file with the same data called “ football.txt” you would type “ cp soccer.txt football.txt”
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

In order to remove files or directories inside of Linux command line what command would you use?

A
  • “rm” . Removes files or directories( Deletes the files)
  • Note this does not remove directories by default. Directories must be empty to be removed first however you can use the “-r” command extension after the “ rm” command to tell it to delete the directory and all files inside as well.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

If you wanted to create a directory inside of Linux command line what command would achieve this for you?

A
  • “mkdir”. Make a directory. Creates a folder for file storage.
  • For example if you wanted to create a directory named “manuals” you would type the command “ mkdir manuals”
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What command in Linux would allow you to adjust the read, write and execute permissions associated with a particular file?

A
  • “chmod”. Change mode of a file system object.
  • Options for this are r = read, w=write, x=execute.
  • You can also use octal notation to separate modes for invividual users and groups. Set for file owner(u), the group(g), others(o), or all(a).
  • To change the read, write permissions for a file named “script.sh” in Linux command line where the User is allowed to read, write and execute that file, however the group should only be able to read it as would others you would type : “ chmod 744 script.sh”. This is because in Linux after the command “ chmod”

0 = no rights(—),

1 = Execute only(–x),

2 = Write only(-w-),

3= Write and Execute(-wx),

4= Read only(r–),

5= Read and execute(r-x),

6= Read and Write(rw-) and

7= Read, Write and Execute(rwx).

  • This is because r=read, w=write and x= execute. So each group of users are assigned a 3 character long read and write permissions using this numbering and lettering scheme.

And the User’s 3 digits are displayed first, Then the groups, and finally Others. So for the string 744 after the chmod command the 7 would be referring to the User, the 4 to the group and the other 4 for others. So for this command is saying the User get’s full read, write and execute permissions(7 or r-w-x) whereas the group and others only have read permissions( 4 or r–) this can be verified by using the “ ls -l” command.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

There are a number of shortcuts that can be used with the cdmod command such as?

A
  • In the previous example we used the “ chmod 744 script.sh” command to specify that for that file the user had read, write and execute privileges whereas the group and others onl had read permissions.
  • However this could be simplified by using the “ chmod a” command which tells it that this command will be associated with all users and then by typing “-w” after the “chmod a” command you will tell the system that there is to be no writing to script.sh. So full command would be “chmod a-w script.sh”
  • Another example would be to tell the system to allow the owner of the file “ script.sh” to be able to execute it only. You could type “ chmod u+x” the “+x” tells the system that you want to add execute privileges and the “u” signifies the owner of the script.sh file.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What command would you use In order to tell the system in command line to change the user and group ownership of a file?

A
  • “chown”. Change the file owner and group. Modify file settings.
  • E.G. type “ sudo chown [OWNER:GROUP] file “ to tell the system to provide elevated permissions that will be required to change the file ownership to a particular group name which is provided and then the name of the file of which you are changing the ownership of.
  • Another example would be to change the ownership of a file named “ football.txt” to be owned by a user named “professor” you would type the command “sudo chown professor football.txt”:
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

If you wanted to view the wireless network configuration of a system in Linux what command could you use?

A
  • “iwconfig”. View or change a wireless network configuration.
  • Things that can be viewed and changed include: essid, frequency/channel, mode, rate etc.
  • Does require some knowledge of the wireless network.
  • An example of a command you could use would be “ iwconfig eth0 essid studio-wireless” .iwconfig(lists the wireless network settings, eth0(names the NIC name) and finally the essid studio-wireless section tells the system to rename the SSID of the wireless connection to studio-wireless.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

If you wanted to view the network configuration of a wired ethernet system in Linux what command could you use?

A
  • “ifconfig” . View or configure network interface and IP configuration.
  • to configure the network settings for a NIC called “eth0” you would type “ ifconfig eth0”.
  • ** Note in some linux distributions the “ifconfig” command is not available and has been migrated to the “ip” command instead. So to view the network configuration in that instance you would type the command “ ip address” instead.
17
Q

If you run into a Linux distribution that doesn’t have the command you are looking for or doesn’t understand it how can you add the command?

A
  • Using the “apt-get” command.
  • Advanced packaging tool. Handles the management of application packages as well as utilities.
  • This tool will allow you to install and remove applications that will give you the ability to use the command you want
  • E.G. you would use the command “sudo apt-get install wireshark” to install the application named Wireshark.
  • Another example would be if your Linux version doesn’t recognize the “ifconfig” command. You can install it by typing “ sudo apt-get install net-tools” and now your system should recognize the “ifconfig” command
18
Q

Similar to the task manager in Windows what command would allow you to view all of the current open processes on your system?

A
  • “ps” command
  • View the current processes and the process ID(PID)
  • to view the current processors for the active user just type “ ps” but if you want to see all processes running on the system for all users you would type “ ps -e” to view that info. Note it will be a lot of information so if you want to break it down into pages type “ ps -e | more” to break down the info into single pages
19
Q

In order to be able to edit the configuration files to make configuration changes to many applications what command would you use?

A
  • “vi”
  • Visual mode editor( Full screen editing with copy, paste and more
  • To Start the editor you would type “ vi” then the name of the file so e.g. “ vi script.sh”. Once inside the editor you can edit text by typing “i” and then the text you want to insert and you can exit this mode by typing “ Esc”
  • To then save the edited file and quit the visual mode editor you would type “ :wq”
20
Q

In Linux what command would allow you to backup and restore an entire partition to an image in Linux?

A
  • “dd” Convert and copy a file but can do much more
  • Backup and restore an entire partition.
  • For example to create a image/backup a partition named “ dev/sda” you would use the full command :
    “ dd if=/dev/sda of= /tmp(folder location for backup)/sda-image.img. And then to restore the imaged backup you would type :
    “ dd if= /tmp/sda-image.img of= /dev/sda

** Notes this works the same for creating copies of iso files to a partition. Which again would be dd if=(/name.iso) of= ( Where you would like to make a copy to. e.g. drive name which will start with /dev/”something like sda” to id the drive being copied to.

21
Q

What commands would you use to close down an application or program?

A
  • First have to make sure you have the proper permissions to do so. So you must use “ sudo” in front of the appropriate command.
  • To close all instances of an application such as firefox you would use the “killall” command in conjunction with the “sudo” command. So the full command to close all instances of Firefox would be :
    “ sudo killall firefox”
  • Note there is also a graphical method for this called “ xkill”
  • Alternatively you can also kill the process or application by typing “ kill” and then the PID.
22
Q

What are the 7 modes of file ownership when it comes to the chmod command inside Terminal?

A

0= no rights(—),

1 = Execute only(–x),

2 = Write only(-w-),

3= Write and Execute(-wx),

4= Read only(r–),

5= Read and execute(r-x),

6= Read and Write(rw-) and

7= Read, Write and Execute(rwx)