Lnx Flashcards

1
Q

How to list all packages installed in ubuntu?

A

dpkg –list

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

How to un-install a package in ubuntu?

A

first check out the exact name of the packgae with the command,

dpkg –list
dpkg –list | grep cde

Make sure it does not appear in dpkg –list
Remove exact package name

sudo apt-get remove exact_pkg_name

Purge any related code

sudo apt-get purge exact_pkg_name

Then Autoremove

sudo apt-get autoremove

Finally, do a clean to check everything is correctly removed.

sudo apt-get clean

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

Linux: What is sshpass command?

A

Find out about it.

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

Linux: How to run a command on a remote machine.

A

Use ssh,
ssh laeeq@192.168.0.49 ls /tmp
ssh laeeq@192.168.0.49 date

you may have to give absolute path of the command you want to execute.

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

Linux: How to find state of a port (3000)?

A

sudo lsof -i:9950 # Linux
netstat -an | grep 9550 # Linux
netstat -an | find /I “9550” # Windows

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

What is tcpdump command to get traffic to/from port 3000

A

sudo tcpdump -i any port 3000

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

Raspberry pie: What to do if keyboard does not type right characters?

A

setxkbmap –layout us

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

Raspberry pie: how to install nodejs on it?

A

wget
http://node-arm.herokuapp.com/node_latest_armhf.deb

sudo dpkg -i node_latest_armhf.deb

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

vimdiff: what are commands?

A

CTL-ww swhitches windows
do: diff obtain, get difference from other window
dp: diff put: send difference to other window
]c: go to next diff
[c: go to previous diff
zo: open zip
zc: close zip

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

Raspberry pie: How to clone a card

A

Both cards should be equal size and make?
On a linux machine, insert master card, find its device name,

sudo fdisk -l
say it is /dev/sdb

create card image,

create card image,

sudo dd if=/dev/sdb | gzip > /tmp/image_name.gz

burn, image on other card, put other card on linux PC,

sudo gzip -dc /tmp/image_name.gz | sudo dd bs=4M of=/dev/sdb

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

Name some popular virtualization providers.

A

VMware & VirtualBox (By Oracle)

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

What is new command to find IP address in place of ifconfig?

A

ip
ip address
man ip

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

Ubuntu: How to find which package provides a file?

A

dpkg -S /bin/ls
coreutils: /bin/ls

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

Linux: how to force core file generation from a crashing program.

A

ulimit -c unlimited

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

Linux: how to display current resource limits for a user?

A

ulimit -a

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

Linux: How to list out all break points set in a program (gdb)?

A

info breakpoints. Each break point is given a number.
To delete a brk pt,
delete 3

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

gdb: How to print value of a variable x, each time program stops at a break pt?

A

display x

18
Q

gdb: How to watch a variable x, so program stops each time that variable changes.

A

set a watch point using,
watch x

19
Q

gdb: How to set a conditional break pt?

A

b fileName.c:56 if x==50

20
Q

gdb: Describe various kinds of watch points.

A

watch x : breaks program each time x changes. Stops at line after the x is changed.

rwatch x : breaks program when x is read.

awatch x: breaks program when x is accessed (read/write or used in any manner).

21
Q

Linux: What happens when you delete a symbolic link.

A

Target remains unaffected.
However, if u delete the target, the symbolic link continues to point to non-existing target file (this called dangling/orphaned symbolic links).

22
Q

what does the ‘tee’ command do?

A

tee cmd is used to copy the output of a command to a file. The regular output of the command is also copied to a file.

wc -l | tee file1.txt

to append to a file instead of overwriting,

wc -l | tee -a file1.txt

23
Q

Lnx: How is HereDocument used?

A

With HereDocument, we can make multiline text available to a command, without using a text file.

cat &laquo_space;ABCD
line 1111
line 222
line 333
ABCD

24
Q

LNX: How to make a variable available inside a shell script?

A

TARGET=x86 ./script.sh

Value of TARGET will be available inside script.sh

25
Q

LNX: How to read a variable inside a shell script from keyboard?

A

read variableName
echo $variableName

26
Q

Lnx: What is a common usage of xargs?

A

It can be used to apply a command to files generated by another command.Following can be used to delete all header files found by cmd find

find . -name “*.h” | xargs rm -v

27
Q

In make file what happens when an error occurs at any time?

A

Default behaviour: Make program is aborted immediately, no further commands are executed.

If you pre-append minus sign ‘-‘ to any command, error in that command will be ignored and next command will be executed.

If you pre-append ‘@’ to any command, make will not print that command before executing.

28
Q

What is make file suffix rule to obtain object file from source file?

A

.c.o:
cc -c $

29
Q

How to run a makeFile in a different directory from original makeFile.

A

cd subDir && $(MAKE)

or

$(MAKE) -C subDir

30
Q

What are common automatic variables in makefiles?

A

$@ : name of current target.
$^ : list of all dependencies
$< : First dependency in the list of dependencies.

31
Q

gdb: How to get the sequence of function calls leading to current point of execution?

A

bt
backtrace
Each stack frame will have a number associated with it. Top most stack frame will be most recent one.

32
Q

gdb: How to get arguments passed to current function?

A

info args

33
Q

gdb: How to get the local variables in current function?

A

info locals

34
Q

Command line editing: Go to begining of line.

A

CTL a

35
Q

Command line editing: Go to end of line.

A

CTL e

36
Q

Command line editing: Delete from cursr posn to end of line

A

CTL k

37
Q

Command line editing: Clear the whole current line

A

CTL AK

38
Q

iptables: name three chains

A

INPUT chain, OUTPUT chain, FORWARD chain

39
Q

What to remember when creating an iptable rule?

A

setup both input chain rule & output chain rule.

40
Q

What is an iptables policy?

A

Each chain has a policy, ACCEPT or DROP.

ACCEPT: Allow all pkts unless a specific rule forbids that kind of pkt.

DROP: Disallow all pkts unless a specific rule allows that kind of pkt.

41
Q

iptables: list all rules

A

iptables -L -v –line-numbers

42
Q

Delete all rules from iptables

A

iptables -F
– or –
iptables -X