Bash Flashcards

1
Q

for loop

A

for i in cat text.log
do
echo $i
done

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

awk

  1. simple separation and print
  2. run command based on output
A
  1. echo $TEXT | awk -F” “ ‘{ print $1 }’

2. echo $TEXT | awk -F” “ ‘{ for(i=1;i<=NF;i++) { system(“echo “ $i) } }’

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

Create a loopback interface

A

tcpdump -D #check interfaces
ifconfig lo1 create #create loopback interface
ifconfig lo1 #cehck loopback 1 status
ifconfig lo1 up #start lo1 interface
ifconfig lo1 inet 192.168.144.25/32 #assign IP to lo1
ifconfig lo1 down
ifconfig lo1 destroy

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

What is a loopback address?

A

Loopback interface is a software driven interface, and are not bound to any network interface cards(NICs); are always in UP state unless manually turned down or if the router is down. This makes it very good option to monitor the router’s availability.
If we monitor a router using an IP, that is attached to a NIC; we just monitor the NIC, if the NIC goes down, that doesn’t mean that the whole router is down.

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

Add space to AWS EC2 machine

A

lsblk #shows the size of the disks available.

sudo su
growpart /dev/xvda 1 #increases the size of the first partition to the available space.

resize2fs /dev/xvda1 #increment the file system size to use all avaialable space on the partition.

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

How to archive using tar

A

tar -czvf myDir.tar.gz myDir
tar -xzvf myDir.tar.gz

tar -tzvf myDir.tar.gz #list the contents of tar file.

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

Create Soft links

A

ln -s /opt/myDir/foo.exe /usr/local/bin/foo

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

Print multiple lines with echo

A

echo -e “adadas \n awdasd \n asdasd”

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