You are on page 1of 3

You cannot kill a K threads in linux ..

Some states of process in linux :


S-sleep interruptable
R-Runnable
Z-Zombie
D-sleep unterrruptable
t-traced process
I-idle
X-terminated

In linux:
/proc/kcore

String output and then read into file to find all the text entered in the system
after reboot….

chroot()
chdir()

get_clocktime() only system call from user space itself doest involve kernelspace.

Conatiner: Unshare in linux..-to invoke new namespace ,to insulate from all the
other processes.

Kill -9 procid

NUMA architecture

Grep ^Vm /proc/<procId>/status —to watch the status of the process

We can check a process is a cpu intensive or I/o intensive


/proc/processid/status. Check last 2 lines vaultery,involentary..

cut -f<id> -d’ ‘ /proc/procid/stat —for checking any value of a process in


linux.

Oomkill ,tom score search on this…..

vim/linux shortcuts/commands:

to find all files having a specific text in linux:


‘ '/path/to/somewhere/' -e 'pattern'

To replace a word with another word in vim:

Go to your word, hit *, and do :%s//replacement/gc When no search pattern is used,


last search pattern, taken from register @/, is used.
Commenting with #:
1. visually select the text rows (using V as usual)
2. :norm i#
This inserts "#" at the start of each line. Note that when you type : the range
will be filled in, so it will really look like :'<,'>norm i#

Uncommenting #:
1. visually select the text as before (or type gv to re-select the previous
selection)
2. :norm x
This deletes the first character of each line. If I had used a 2-char comment such
as // then I'd simply do :norm xx to delete both chars.

replace a pattern with another pattern in a file in vim:

:%s/foo/bar/g

to tar a whole directory in linux:

tar -zcvf archive-name.tar.gz directory-name

to untar a whole directory of tar.gz type in linux:

tar -zxvf yourfile.tar.gz

Setup a tftp server:

https://tournasdimitrios1.wordpress.com/2011/02/22/setup-tftp-server-on-centos/

https://linuxize.com/post/how-to-stop-and-disable-firewalld-on-centos-7/

yum install tftp-server


yum install xinetd
chkconfig tftp on
chkconfig xinetd on
service xinetd start
chmod 777 /tftpboot

yum install tftp


tftp -v 192.168.1.50 -c put file-example.txt
tftp -v 192.168.1.50 -c get file-example.txt

cat /etc/xinetd.d/tftp
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/lib/tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}

and turn off firewall on dhcp server

sudo firewall-cmd --state


sudo systemctl stop firewalld

Create a process with two threads ,reader thread , writer thread

Global structure
Int a=0;
Int b=0;

Writer upadews. a+=10,b=a+5 in a loop with sleep of 5 sec and reader will
read(print) structure and sleep for 10 sec.

Locking the data structure— so that read always prints correct values.

Also Implement the structure to be in shared memory using two independent threads.
Done ✅

Create a program with infinite white loop


ps | grep
/proc/id/mem.. — cat the memory file of the process and understand it

And now do malloc inside the while loop with sleep and now observer the same
memory file and observe the difference.

Declare global, static ,malloc pointers and observe where they will be with respect
to above memory file.

Try to overutizie malloced memory and compare last address overutilizing against
the memory map.

malloc(20)

Do a shared memory attached to while loop program and print shared memory attached
address;. Done ✅

You might also like