General Flashcards

0
Q

How would you replace the word linux with linux-KT in a file called samples.txt

A

sed ‘s/linux/linux-KT’ samples.txt

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

How to copy a directory and it’s sub directories to a new location?

A

cp -R /keith /cathy

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

What is sed use for matching?

A

Regular expressions

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

How would you use sed to replace the second occurrence of a word?

A

sed ‘s/linux/linux-KT/2’ samples.txt

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

How would you delete the last 3 characters of each line in a file using sed?

A

sed ‘s/…$//’ samples.txt

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

How would you string two commands together in sed?

A

Using the ;

Example:
sed -e ‘s/#.*//;/^$/d’ thegeekstuff.txt

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

What is sed used for?

A

Searching and replacing in text files?

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

How would you search for text in all files in directories and sub directories?

A

grep -RnisI *

Search for a string inside all files in the current directory
This is how I typically grep. -R recurse into subdirectories, -n show line numbers of matches, -i ignore case, -s suppress “doesn’t exist” and “can’t read” messages, -I ignore binary files (technically, process them as having no matches, important for showing inverted results with -v)
I have grep aliased to “grep –color=auto” as well, but that’s a matter of formatting not function.
Add to favourites | Report as malicious

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

How to get current directory?

A

pwd

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

What is linux cut command used for?

A

extract portion of text from a file by selecting columns.

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

What is dd used for in linux?

A

dd can be used to raw copy a uncounted disk to a file.

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

What command could I use to get disk io?

A

Iostat

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

When swing top on a server with a processor with 4 cores, if the lode average is 4.57, is their processes having to wait ?

A

Yes

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

What are the 3 load average times when using top?

A

Last min
5 min
15 min

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

In a linux terminal how would you clear the screen?

A

ctrl-l

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

How would you search for a package?

A

apt-cache search

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

How would you get a lists of all installed packages?

A

dpkg -l

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

What syntax would you use to do the following, execute the next command if the current command was successful?

A

&&

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

What syntax would you use to have the next command execute if the current command failed to execute?

A

||

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

How can you string two or more commands together?

A

ls ; ls

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

What command would you use to get PCI info?

A

lspci -T -V

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

What command would you use to get a list of hardware info?

A

lshw

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

How can you get the nap client to update again a ntp ?service

A

ntp date -s ntp.ubuntu.com

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

How would you upgrade a package in linux?

A

apt-get upgrade

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

How would you upgrade all software in linux ?

A

apt-get upgrade

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

How would you upgrade the linux distribution?

A

apt-get dist-upgrade

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

How would you remove a package and it’s config files from linux?

A

apt-get purge

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

How would you clean out files from local repositories ?

A

Clean

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

What is the location of the cache directories associated with the clean command?

A

/var/cache/apt/archives/ and /var/cache/apt/archives/partial/

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

Where is the repo sources for apt-get

A

/etc/apt/sources.list

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

How would you do a apt-get install and simulate the operations?

A

apt-get -s install

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

With apt-get how would you simulate actions?

A

Use the -s flag

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

How to change current user password

A

passwd

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

How to shutdown the Linux OS

A

shutdown now

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

How to reboot the Linux OX

A

reboot

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

How can we create a tar

A

tar cvzf archive_name dirname/

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

How can we extract a tar file

A

tar xvf archive_name.tar

37
Q

How can we view the continence of a tar

A

tar tvf archive_name.tar

38
Q

How can you execute on each file found with the find command?

A

find -iname “MyCProgram.c” -exec md5sum {} \;

39
Q

Debug ssh

A

ssh -v -l jsmith remotehost.example.com

40
Q

How do you export MYVAR

A

export MYVAR=xxxxxxxxxx

41
Q

How do you restart ssh service?

A

service ssh restart

42
Q

How do you get the status of a service?

A

service ssh restart

43
Q

Check the status of all services?

A

service –status-all

44
Q

How can you from command line erase a complete line

A

ctrl-u

45
Q

How to delete last word typed in cli?

A

ctrl-w

46
Q

How to cancel current operation?

A

ctrl-c

47
Q

How to paste previous line?

A

ctrl-p

48
Q

If terminal is gone a bit wonky, how would you make it good a gain?

A

reset

49
Q

On command line how can you move between args quickly?

A

ctrl-left ctrl-right

50
Q

On command line how would you mover the curser to the end of the line quickly?

A

ctrl-e

51
Q

On the command line how would you move to the begining of the line quickly?

A

ctrl-a

52
Q

From command line how can you search the history for something?

A

ctrl-r xxxx

53
Q

On cli how do you delete a line before the curser?

A

ctrl-w

54
Q

On cli how to delete line from curser to end of line?

A

ctrl-k

55
Q

How can you have command repeated ever 5 sec?

A

watch -n 5 “tail -n /var/log/sys log”

56
Q

How can you see the last 30 lines of a file?

A

tail -n 30

57
Q

How to show/list all hidden files?

A

ls -a

58
Q

How to kill a process bu name?

A

kill nano

59
Q

Using scp to to copy a file from local server to remote?

A

scp @:

scp filename username@host:/path/to/other/destination/directory

60
Q

With scp to to copy a file from remote to local?

A

$ scp your_username@remotehost.edu:foobar.txt /some/local/directory

61
Q

With scp how to copy a directory from local to remote?

A

$ scp -r foo your_username@remotehost.edu:/some/remote/directory/bar

62
Q

When using the ‘ps aux’ command, what dose the ‘a’ mean?

A

-a means all process.

63
Q

When using the ‘ps aux’ command, what dose the ‘u’ mean?

A

-u select the users that exist in the user list

64
Q

How would you get a lists of users?

A

cat /etc/passed

65
Q

With ps how would you return the command and args used to start the process?

A

ps aux -o args

66
Q

How to display a process threads?

A

ps aux -m

67
Q

When using ps command how would you get full format info?

A

-f

68
Q

What command to use to get the machine hardware clock?

A

how clock

69
Q

What command to use to write the linux clock to the hardware clock?

A

hwclock -w

70
Q

How to set the hardware date and time manually?

A

hwclock –set –date “8/11/2013 23:10:45”

71
Q

How to get a list of kernal modules?

A

lsmod

72
Q

How to install a module in kernal?

A

insmod keith.ko

73
Q

How to remove module from kernal?

A

rmmod keith.ko

74
Q

How to get info about a kernal module?

A

modinfo /lib/modules/3.5.0-19-generic/kernel/fs/squashfs/squashfs.ko

filename: /lib/modules/3.5.0-19-generic/kernel/fs/squashfs/squashfs.ko
license: GPL
author: Phillip Lougher
description: squashfs 4.0, a compressed read-only filesystem
srcversion: 89B46A0667BD5F2494C4C72
depends:
intree: Y
vermagic: 3.5.0-19-generic SMP mod_unload modversions 686

75
Q

How to get the first 10 lines of a text file?

A

head -n 10

76
Q

How to find files modified in last 5 min?

A

find / -cmin -5

77
Q

How to find files modified in last two days?

A

$ find /target_directory -type f -mtime -2

78
Q

How to use top to monitor a process by its id?

A

top -p

79
Q

Using top how would you monitor all user process?

A

top -u keith

80
Q

How to get a list of open files?

A

ls of

81
Q

How would you monitor system calls and signals in a program?

A

sstrace

82
Q

How to use strace to monitor a existing program?

A

strace -c

83
Q

When using strace how can you write to a file?

A

-o flag

stace -p -o /tmp/dog.txt

84
Q

How to get a package dependacys?

A

apt-cache depends ssh

85
Q

What is apt-get update used for?

A

Used to re-synchronize the package index files from their sources.

86
Q

What is apt-get upgrade used for?

A

Used to install the newest versions of all packages currently installed on the system from the sources enumerated in /etc/apt/sources.list(5).

87
Q

What is apt-get dist-upgrade used for?

A

In addition to performing the function of upgrade, this option also intelligently handles changing dependencies with new versions of packages; apt-get has a “smart” conflict resolution system, and it will attempt to upgrade the most important packages at the expense of less important ones, if necessary.

88
Q

What is the wc command used for

A

wc - print the number of bytes, words, and lines in files

89
Q

What is the dig command used for?

A

To query dns server for info?