User Tools

Site Tools


Sidebar

os_cp:files_processes:solutions

1mkdir foo
mkdir foo/baz
mkdir -p foo/baz/bar foo/bar foobaz/bar
2rmdir foo/baz/bar
rmdir foo/baz
3echo "foo" > file1
ln file1 file2
echo "bar" > file2
cat file1
4cd
ln -s /tmp TMP
cd TMP
pwd
5# second column of "ls -l" results
ln -s /tmp ~/TMP
cd ~/TMP
pwd
6cd
ln -s . loop
cd loop
cd loop
pwd
7ln -s /nonexistent/path brokenSymlink
ls -l
8cp /etc/os-release /etc/SUSE-brand .
10cp -a someDir newDir
11mv newDir someDir
12mv someDir anotherDir
13cp -al anotherDir yetAnotherDir
echo "modified" > yetAnotherDir/file2
tree -D --timefmt=%H:%M:%S anotherDir yetAnotherDir
# fileów anotherDir/file2 i yetAnotherDir/file2
14cd /tmp
touch example
scp example student@lab-sec-1:example
cd /tmp
touch example
scp example student@lab-sec-1:
15scp /tmp/example student@lab-sec-1:/tmp
16cd /tmp
sftp student@lab-sec-1
sftp> cd /tmp
sftp> put example
sftp student@lab-sec-1
sftp> cd /tmp
sftp> put /tmp/example
sftp student@lab-sec-1
sftp> cd /tmp
sftp> lcd /tmp
sftp> put example
17touch file_{a..z}
rm file_?
touch file_{a..z}
rm -f file_?
18rm file_?
rm -f file_?
19mkdir someDir
rm -r someDir
20sleep 2
21time sleep 2
22time openssl dhparam -text 1536
23timeout 5s openssl dhparam -text 2048
24ps
25ps -l
ps -f
ps -F
ps u
26ps -e
ps ax
27ps -T
# a process with two threads is displayed as two lines with same pid (and different tids)
ps -L
28pstree
ps -eH
29pstree -p
ps -eH
30cat /proc/self/status
# the status is shown for the cat process
32top
# 'P' / 'M' sort by CPU / memory, besides '<' and '>' select sort columns
33# Running, Sleeping, D → stalled on I/O (disk access), t → paused while debugging, Zombie
34htop
# '<' and '>' opens a sort menu
# or: mouse click on column name
35htop
# 'F5' and 't' toggle tree view
# 'F3' and '/' search, once search term is set, 'F3' jumps to ext occurrence
36sleep 1h
pgrep sleep
sleep 1h
pidof sleep
sleep 1h
pgrep -f 'sleep 1h'
37sleep 1337h
sleep 42h
pgrep -f '1337h'
38pgrep 'gdm$'
pidof gdm
39sleep 1h
pgrep sleep
# or e.g., ps -e , pstree -p , htop …
kill pid
40sleep 1h
pkill sleep
41# select "run…" from the panel, input "mousepad"
pkill -STOP mousepad
# notice that mousepad froze
pkill -CONT mousepad
# mousepad is now responsive
42named -g -c <(:)
pkill -HUP named
# named states that it reloaded all configuration and zone files
43nice -n 10 sleep 1h
ps -el
# or htop
44sleep 1h
pgrep sleep
renice 15 pid
45taskset -pc 0 $$
openssl dhparam -text $((2**14))
# ×2
htop
# limit results to openssl by 'F4' or '\'
# 'F8' increases niceness
taskset -pc 0 $$
openssl dhparam -text $((2**14)) foobazbar
# ×2
htop
# search for openssl with 'F3' or '/'
pgrep -f foobazbar
renice -n 1 pid
renice -n 2 pid
...

os_cp/files_processes/solutions.txt · Last modified: 2023/04/02 11:13 by jkonczak