General Flashcards

(90 cards)

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
How would you upgrade all software in linux ?
apt-get upgrade
25
How would you upgrade the linux distribution?
apt-get dist-upgrade
26
How would you remove a package and it's config files from linux?
apt-get purge
27
How would you clean out files from local repositories ?
Clean
28
What is the location of the cache directories associated with the clean command?
/var/cache/apt/archives/ and /var/cache/apt/archives/partial/
29
Where is the repo sources for apt-get
/etc/apt/sources.list
30
How would you do a apt-get install and simulate the operations?
apt-get -s install
31
With apt-get how would you simulate actions?
Use the -s flag
32
How to change current user password
passwd
33
How to shutdown the Linux OS
shutdown now
34
How to reboot the Linux OX
reboot
35
How can we create a tar
tar cvzf archive_name dirname/
36
How can we extract a tar file
tar xvf archive_name.tar
37
How can we view the continence of a tar
tar tvf archive_name.tar
38
How can you execute on each file found with the find command?
find -iname "MyCProgram.c" -exec md5sum {} \;
39
Debug ssh
ssh -v -l jsmith remotehost.example.com
40
How do you export MYVAR
export MYVAR=xxxxxxxxxx
41
How do you restart ssh service?
service ssh restart
42
How do you get the status of a service?
service ssh restart
43
Check the status of all services?
service --status-all
44
How can you from command line erase a complete line
ctrl-u
45
How to delete last word typed in cli?
ctrl-w
46
How to cancel current operation?
ctrl-c
47
How to paste previous line?
ctrl-p
48
If terminal is gone a bit wonky, how would you make it good a gain?
reset
49
On command line how can you move between args quickly?
ctrl-left ctrl-right
50
On command line how would you mover the curser to the end of the line quickly?
ctrl-e
51
On the command line how would you move to the begining of the line quickly?
ctrl-a
52
From command line how can you search the history for something?
ctrl-r xxxx
53
On cli how do you delete a line before the curser?
ctrl-w
54
On cli how to delete line from curser to end of line?
ctrl-k
55
How can you have command repeated ever 5 sec?
watch -n 5 "tail -n /var/log/sys log"
56
How can you see the last 30 lines of a file?
tail -n 30
57
How to show/list all hidden files?
ls -a
58
How to kill a process bu name?
kill nano
59
Using scp to to copy a file from local server to remote?
scp @: | scp filename username@host:/path/to/other/destination/directory
60
With scp to to copy a file from remote to local?
$ scp your_username@remotehost.edu:foobar.txt /some/local/directory
61
With scp how to copy a directory from local to remote?
$ scp -r foo your_username@remotehost.edu:/some/remote/directory/bar
62
When using the 'ps aux' command, what dose the 'a' mean?
-a means all process.
63
When using the 'ps aux' command, what dose the 'u' mean?
-u select the users that exist in the user list
64
How would you get a lists of users?
cat /etc/passed
65
With ps how would you return the command and args used to start the process?
ps aux -o args
66
How to display a process threads?
ps aux -m
67
When using ps command how would you get full format info?
-f
68
What command to use to get the machine hardware clock?
how clock
69
What command to use to write the linux clock to the hardware clock?
hwclock -w
70
How to set the hardware date and time manually?
hwclock --set --date "8/11/2013 23:10:45"
71
How to get a list of kernal modules?
lsmod
72
How to install a module in kernal?
insmod keith.ko
73
How to remove module from kernal?
rmmod keith.ko
74
How to get info about a kernal module?
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
How to get the first 10 lines of a text file?
head -n 10
76
How to find files modified in last 5 min?
find / -cmin -5
77
How to find files modified in last two days?
$ find /target_directory -type f -mtime -2
78
How to use top to monitor a process by its id?
top -p
79
Using top how would you monitor all user process?
top -u keith
80
How to get a list of open files?
ls of
81
How would you monitor system calls and signals in a program?
sstrace
82
How to use strace to monitor a existing program?
strace -c
83
When using strace how can you write to a file?
-o flag stace -p -o /tmp/dog.txt
84
How to get a package dependacys?
apt-cache depends ssh
85
What is apt-get update used for?
Used to re-synchronize the package index files from their sources.
86
What is apt-get upgrade used for?
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
What is apt-get dist-upgrade used for?
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
What is the wc command used for
wc - print the number of bytes, words, and lines in files
89
What is the dig command used for?
To query dns server for info?