Linux Practice

20
1. Use find to compile a list of all directories in the system, redirecting the output so that the list of directories ends up in a file called directories.txt and the list of error messages ends up in a file called errors.txt. Use below command to listout all the directories in the system: find / we can direct the errors to the errors.txt by below command: find / 2>errors.txt and we get directories by below command: find / 2>errors.txt >> directories.txt 2. Try the command sleep 5. What does this command do? It gives delay for 5 seconds 3. Run the command in the background using &. It can be done by using below command: sleep 5 & by this command we can't see the delay process,but can be seen by using command 'ps'. 4. Run sleep 15 in the foreground, suspend it with Ctrlz and then put it into the background with bg. Type jobs. Type ps. Bring the job back into the foreground with fg. Follow the steps: 1.sleep 15 2.ctrl + z

description

This is an exercise for linux beginner

Transcript of Linux Practice

Page 1: Linux Practice

1. Use find to compile a list of all directories in the system, redirecting the output so that the list of directories ends up in a file called directories.txt and the list of error messages ends up in a file called errors.txt.

Use below command to listout all the directories in the system:

find /

we can direct the errors to the errors.txt by below command:

find / 2>errors.txt

and we get directories by below command:

find / 2>errors.txt >> directories.txt

2. Try the command sleep 5. What does this command do?

It gives delay for 5 seconds 3. Run the command in the background using &.

It can be done by using below command:

sleep 5 &

by this command we can't see the delay process,but can be seen by using command 'ps'. 4. Run sleep 15 in the foreground, suspend it with Ctrlz and then put it into the background with bg. Type jobs. Type ps. Bring the job back into the foreground with fg.

Follow the steps:

1.sleep 152.ctrl + z

^Z[1]+ Stopped sleep 15

3.bg[1]+ sleep 15 &

4.jobs[1]+ Running sleep 15 &

5.psPID TTY TIME CMD3133 pts/1 00:00:00 bash

3231 pts/1 00:00:00 sleep 3232 pts/1 00:00:00 ps6.fg

sleep 15

Page 2: Linux Practice

5. Run sleep 15 in the background using &, and then use kill to terminate the process by its job number. Repeat, except this time kill the process by specifying its PID.

For terminate the process by its job no,use below command:

kill %<job no.>

> ex:follow below steps:

1.sleep 15 &[1] 3454

2.jobs[1]+ Running sleep 15 &

3.kill %14.jobs

[1]+ Terminated sleep 15

For terminate the process by its pid no,use below command:

kill <PID no.>

> ex:follow below steps:

1.sleep 15 &[1] 3289

1.kill 32892.jobs

[1]+ Terminated sleep 15

6. Run sleep 15 in the background using &, and then use kill to suspend the process. Use bg to continue running the process.

>kill to suspend use command: kill -STOP <PID no.>

>follow the steps:

1.sleep 15 &[1] 3514

2.jobs[1]+ Running sleep 30 &

3.kill -STOP 3514 [1]+ Stopped sleep 304.bg

[1]+ sleep 30 &5.jobs

[1]+ Running sleep 30 &

Page 3: Linux Practice

7. Startup a number of sleep 60 processes in the background, and terminate them all at the same time using the pkill command.

>pkill -g <pid1>,<pid2>,<pid3>,.......

>follow the steps:

1.create the several processes using command:sleep 60 &

2.pkill -g 4071,4072,4073,4074,4075

[12] Terminated sleep 60[13] Terminated sleep 60[14] Terminated sleep 60[15]- Terminated sleep 60[16]+ Terminated sleep 60

8. Use ps, w and top to show all processes that are executing.

>ps

PID TTY TIME CMD 4002 pts/1 00:00:00 bash 4091 pts/1 00:00:01 top 4092 pts/1 00:00:00 top 4094 pts/1 00:00:00 top 4096 pts/1 00:00:00 sleep 4097 pts/1 00:00:00 ps

>w

11:24:07 up 1:39, 3 users, load average: 0.15, 0.14, 0.14USER TTY FROM LOGIN@ IDLE JCPU PCPU WHATkp tty7 :0 09:44 1:39m 2:57 0.29s gnome-session -kp pts/0 :0 09:48 16:00 1.03s 49.23s gnome-terminalkp pts/1 :0 11:13 0.00s 1.77s 0.00s w

>top

top - 11:22:27 up 1:38, 3 users, load average: 0.20, 0.15, 0.14Tasks: 185 total, 1 running, 182 sleeping, 2 stopped, 0 zombie%Cpu(s): 1.3 us, 0.9 sy, 0.0 ni, 96.9 id, 0.8 wa, 0.0 hi, 0.0 si, 0.0 stKiB Mem: 3885952 total, 3681180 used, 204772 free, 1227008 buffersKiB Swap: 262140 total, 0 used, 262140 free, 1751888 cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 1193 root 20 0 123m 18m 5664 S 4.3 0.5 2:54.93 Xorg 1919 kp 20 0 1148m 86m 30m S 2.3 2.3 2:01.01 compiz

Page 4: Linux Practice

2585 kp 20 0 530m 23m 12m S 2.3 0.6 0:48.35 gnome-terminal 2372 kp 20 0 399m 13m 9.9m S 0.3 0.4 0:01.79 update-notifier 3028 root 20 0 0 0 0 S 0.3 0.0 0:01.91 kworker/u:0 3439 root 20 0 0 0 0 S 0.3 0.0 0:00.54 kworker/0:1 1 root 20 0 24456 2448 1372 S 0.0 0.1 0:00.66 init 2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd 3 root 20 0 0 0 0 S 0.0 0.0 0:00.32 ksoftirqd/0 6 root rt 0 0 0 0 S 0.0 0.0 0:00.00 migration/0 7 root rt 0 0 0 0 S 0.0 0.0 0:00.02 watchdog/0 8 root rt 0 0 0 0 S 0.0 0.0 0:00.55 migration/1 10 root 20 0 0 0 0 S 0.0 0.0 0:00.20 ksoftirqd/1 11 root rt 0 0 0 0 S 0.0 0.0 0:00.02 watchdog/1 12 root rt 0 0 0 0 S 0.0 0.0 0:00.00 migration/2 14 root 20 0 0 0 0 S 0.0 0.0 0:00.29 ksoftirqd/2 15 root rt 0 0 0 0 S 0.0 0.0 0:00.02 watchdog/2

9. Use ps aeH to display the process hierarchy. Look for the init process. See if you can identify important system daemons. Can you also identify your shell and its subprocesses?

>ps -aeH

PID TTY TIME CMD 2 ? 00:00:00 kthreadd 3 ? 00:00:00 ksoftirqd/0 6 ? 00:00:00 migration/0 7 ? 00:00:00 watchdog/0 8 ? 00:00:00 migration/1 10 ? 00:00:00 ksoftirqd/1 11 ? 00:00:00 watchdog/1 12 ? 00:00:00 migration/2 14 ? 00:00:00 ksoftirqd/2 15 ? 00:00:00 watchdog/2 16 ? 00:00:00 migration/3 18 ? 00:00:00 ksoftirqd/3 19 ? 00:00:00 watchdog/3 20 ? 00:00:00 cpuset 21 ? 00:00:00 khelper 22 ? 00:00:00 kdevtmpfs 23 ? 00:00:00 netns 25 ? 00:00:00 sync_supers 26 ? 00:00:00 bdi-default 27 ? 00:00:00 kintegrityd 28 ? 00:00:00 kblockd 29 ? 00:00:00 ata_sff 30 ? 00:00:00 khubd 31 ? 00:00:00 md 34 ? 00:00:00 khungtaskd

Page 5: Linux Practice

35 ? 00:00:00 kswapd0 36 ? 00:00:00 ksmd 37 ? 00:00:00 khugepaged 38 ? 00:00:00 fsnotify_mark 39 ? 00:00:00 ecryptfs-kthrea 40 ? 00:00:00 crypto 49 ? 00:00:00 kthrotld 52 ? 00:00:01 kworker/2:1 53 ? 00:00:00 scsi_eh_0 54 ? 00:00:00 scsi_eh_1 55 ? 00:00:00 scsi_eh_2 56 ? 00:00:00 scsi_eh_3 57 ? 00:00:00 scsi_eh_4 58 ? 00:00:00 scsi_eh_5 62 ? 00:00:02 kworker/u:5 65 ? 00:00:00 binder 85 ? 00:00:00 deferwq 86 ? 00:00:00 charger_manager 87 ? 00:00:00 devfreq_wq 88 ? 00:00:04 kworker/1:1 277 ? 00:00:02 loop0 279 ? 00:00:00 jbd2/loop0-8 280 ? 00:00:00 ext4-dio-unwrit 600 ? 00:00:00 irq/41-mei 632 ? 00:00:00 cfg80211 634 ? 00:00:00 kpsmoused 653 ? 00:00:00 krfcommd 890 ? 00:00:00 kvm-irqfd-clean 1092 ? 00:00:00 hd-audio0 1554 ? 00:00:00 flush-7:0 1555 ? 00:00:00 flush-8:0 2443 ? 00:00:03 kworker/3:2 2766 ? 00:00:00 kworker/1:0 3028 ? 00:00:01 kworker/u:0 3091 ? 00:00:03 kworker/3:1 3439 ? 00:00:00 kworker/0:1 3652 ? 00:00:00 kworker/2:2 4076 ? 00:00:00 kworker/0:0 4095 ? 00:00:00 kworker/0:2 4100 ? 00:00:00 kworker/u:1 1 ? 00:00:00 init 270 ? 00:00:05 mount.ntfs 466 ? 00:00:00 upstart-udev-br 469 ? 00:00:00 udevd 2814 ? 00:00:00 udevd 2815 ? 00:00:00 udevd 590 ? 00:00:01 dbus-daemon 602 ? 00:00:00 bluetoothd 618 ? 00:00:00 avahi-daemon

Page 6: Linux Practice

620 ? 00:00:00 avahi-daemon 655 ? 00:00:00 rsyslogd 658 ? 00:00:00 cupsd 803 ? 00:00:00 modem-manager 844 ? 00:00:00 upstart-socket- 873 ? 00:00:01 NetworkManager 1611 ? 00:00:00 dnsmasq 3907 ? 00:00:00 dhclient 885 ? 00:00:00 polkitd 911 tty4 00:00:00 getty 920 tty5 00:00:00 getty 934 tty2 00:00:00 getty 939 tty3 00:00:00 getty 942 tty6 00:00:00 getty 957 ? 00:00:00 acpid 958 ? 00:00:00 whoopsie 961 ? 00:00:00 irqbalance 1009 ? 00:00:00 cron 1010 ? 00:00:00 atd 1088 ? 00:00:00 lightdm 1193 tty7 00:03:02 Xorg 1489 ? 00:00:00 lightdm 1839 ? 00:00:00 gnome-session 1874 ? 00:00:00 ssh-agent 1898 ? 00:00:03 gnome-settings- 1969 ? 00:00:03 syndaemon 1919 ? 00:02:04 compiz 2001 ? 00:00:00 sh 2002 ? 00:00:02 gtk-window-deco 1930 ? 00:00:00 polkit-gnome-au 1932 ? 00:00:00 gnome-fallback- 1933 ? 00:00:04 nm-applet 1934 ? 00:00:00 bluetooth-apple 1939 ? 00:00:06 nautilus 2273 ? 00:00:00 telepathy-indic 2372 ? 00:00:01 update-notifier 2473 ? 00:00:00 deja-dup-monito 1112 ? 00:00:01 wpa_supplicant 1205 tty1 00:00:00 getty 1213 ? 00:00:00 accounts-daemon 1231 ? 00:00:00 console-kit-dae 1352 ? 00:00:00 upowerd 1496 ? 00:00:00 colord 1548 ? 00:00:00 rtkit-daemon 1828 ? 00:00:00 gnome-keyring-d 1877 ? 00:00:00 dbus-launch 1878 ? 00:00:01 dbus-daemon 1880 ? 00:00:00 at-spi-bus-laun 1884 ? 00:00:00 dbus-daemon

Page 7: Linux Practice

1887 ? 00:00:00 at-spi2-registr 1906 ? 00:00:00 gvfsd 1910 ? 00:00:00 gvfsd-fuse 1925 ? 00:00:00 dconf-service 1950 ? 00:00:00 gvfs-udisks2-vo 1953 ? 00:00:01 udisksd 1974 ? 00:00:00 pulseaudio 2009 ? 00:00:00 gconf-helper 1977 ? 00:00:00 gvfs-afc-volume 1982 ? 00:00:00 gvfs-gphoto2-vo 1988 ? 00:00:00 gconfd-2 1991 ? 00:00:02 bamfdaemon 1996 ? 00:00:00 gvfsd-trash 2011 ? 00:00:00 gvfsd-burn 2016 ? 00:00:11 unity-panel-ser 2018 ? 00:00:05 hud-service 2031 ? 00:00:00 indicator-sessi 2033 ? 00:00:00 indicator-print 2036 ? 00:00:00 indicator-messa 2037 ? 00:00:00 indicator-datet 2046 ? 00:00:00 indicator-sound 2047 ? 00:00:00 indicator-appli 2063 ? 00:00:00 evolution-sourc 2084 ? 00:00:00 geoclue-master 2096 ? 00:00:00 ubuntu-geoip-pr 2124 ? 00:00:00 unity-webapps-s 2142 ? 00:00:00 unity-applicati 2149 ? 00:00:00 unity-gwibber-d 2150 ? 00:00:00 unity-music-dae 2151 ? 00:00:00 unity-lens-phot 2152 ? 00:00:00 unity-shopping- 2153 ? 00:00:00 unity-files-dae 2154 ? 00:00:00 unity-lens-vide 2202 ? 00:00:00 zeitgeist-daemo 2214 ? 00:00:00 zeitgeist-fts 2222 ? 00:00:00 cat 2216 ? 00:00:00 zeitgeist-datah 2235 ? 00:00:00 unity-musicstor 2237 ? 00:00:00 unity-scope-gdo 2259 ? 00:00:00 unity-scope-vid 2280 ? 00:00:00 mission-control 2286 ? 00:00:00 signon-ui 2315 ? 00:00:00 ubuntuone-syncd 2355 ? 00:00:02 mount.ntfs 2366 ? 00:00:00 gvfsd-metadata 2382 ? 00:00:00 system-service- 2426 ? 00:00:02 notify-osd 2431 ? 00:00:00 gnome-screensav 2585 ? 00:00:50 gnome-terminal

Page 8: Linux Practice

2589 ? 00:00:00 gnome-pty-helpe 2590 pts/0 00:00:00 bash 3540 pts/0 00:00:00 sudo 3541 pts/0 00:00:00 apt-get 4122 ? 00:00:00 dpkg <defunct> 4002 pts/1 00:00:00 bash 4091 pts/1 00:00:01 top 4092 pts/1 00:00:00 top 4094 pts/1 00:00:00 top 4565 pts/1 00:00:00 ps 2928 ? 00:00:06 evince 2934 ? 00:00:00 evinced 3037 ? 00:00:00 oosplash 3058 ? 00:00:38 soffice.bin

10. Combine ps fae with grep to show all processes that you are executing, with the exception of the ps fae and grep commands.

>ps -fae | grep <username>

>Ex:

ps -fae | grep kp

Output:

root 634 2 0 09:44 ? 00:00:00 [kpsmoused]kp 1828 1 0 09:44 ? 00:00:00 /usr/bin/gnome-keyring-daemon --daemonize --loginkp 1839 1489 0 09:44 ? 00:00:00 gnome-session --session=ubuntukp 1874 1839 0 09:44 ? 00:00:00 /usr/bin/ssh-agent /usr/bin/dbus-launch --exit-with-session gnome-session --session=ubuntukp 1877 1 0 09:44 ? 00:00:00 /usr/bin/dbus-launch --exit-with-session gnome-session --session=ubuntukp 1878 1 0 09:44 ? 00:00:01 //bin/dbus-daemon --fork --print-pid 5 --print-address 7 --sessionkp 1880 1 0 09:44 ? 00:00:00 /usr/lib/at-spi2-core/at-spi-bus-launcherkp 1884 1880 0 09:44 ? 00:00:00 /bin/dbus-daemon --config-file=/etc/at-spi2/accessibility.conf --nofork --print-address 3kp 1887 1 0 09:44 ? 00:00:00 /usr/lib/at-spi2-core/at-spi2-registryd --use-gnome-sessionkp 1898 1839 0 09:44 ? 00:00:03 /usr/lib/gnome-settings-daemon/gnome-settings-daemonkp 1906 1 0 09:44 ? 00:00:00 /usr/lib/gvfs/gvfsdkp 1910 1 0 09:44 ? 00:00:00 /usr/lib/gvfs//gvfsd-fuse -f /run/user/kp/gvfskp 1919 1839 1 09:44 ? 00:02:07 compizkp 1925 1 0 09:44 ? 00:00:00 /usr/lib/dconf/dconf-servicekp 1930 1839 0 09:44 ? 00:00:00 /usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1kp 1932 1839 0 09:44 ? 00:00:00 /usr/lib/gnome-settings-daemon/gnome-fallback-mount-helper

Page 9: Linux Practice

kp 1933 1839 0 09:44 ? 00:00:04 nm-appletkp 1934 1839 0 09:44 ? 00:00:00 bluetooth-appletkp 1939 1839 0 09:44 ? 00:00:06 nautilus -nkp 1950 1 0 09:44 ? 00:00:00 /usr/lib/gvfs/gvfs-udisks2-volume-monitorkp 1969 1898 0 09:44 ? 00:00:03 syndaemon -i 2.0 -K -R -tkp 1974 1 0 09:44 ? 00:00:00 /usr/bin/pulseaudio --start --log-target=syslogkp 1977 1 0 09:44 ? 00:00:00 /usr/lib/gvfs/gvfs-afc-volume-monitorkp 1982 1 0 09:44 ? 00:00:00 /usr/lib/gvfs/gvfs-gphoto2-volume-monitorkp 1988 1 0 09:44 ? 00:00:00 /usr/lib/x86_64-linux-gnu/gconf/gconfd-2kp 1991 1 0 09:44 ? 00:00:02 /usr/lib/bamf/bamfdaemonkp 1996 1 0 09:44 ? 00:00:00 /usr/lib/gvfs/gvfsd-trash --spawner :1.7 /org/gtk/gvfs/exec_spaw/0kp 2001 1919 0 09:44 ? 00:00:00 /bin/sh -c /usr/bin/gtk-window-decoratorkp 2002 2001 0 09:44 ? 00:00:02 /usr/bin/gtk-window-decoratorkp 2009 1974 0 09:44 ? 00:00:00 /usr/lib/pulseaudio/pulse/gconf-helperkp 2011 1 0 09:44 ? 00:00:00 /usr/lib/gvfs/gvfsd-burn --spawner :1.7 /org/gtk/gvfs/exec_spaw/1kp 2016 1 0 09:44 ? 00:00:11 /usr/lib/unity/unity-panel-servicekp 2018 1 0 09:44 ? 00:00:05 /usr/lib/indicator-appmenu/hud-servicekp 2031 1 0 09:44 ? 00:00:00 /usr/lib/indicator-session/indicator-session-servicekp 2033 1 0 09:44 ? 00:00:00 /usr/lib/indicator-printers/indicator-printers-servicekp 2036 1 0 09:44 ? 00:00:00 /usr/lib/indicator-messages/indicator-messages-servicekp 2037 1 0 09:44 ? 00:00:00 /usr/lib/indicator-datetime/indicator-datetime-servicekp 2046 1 0 09:44 ? 00:00:00 /usr/lib/indicator-sound/indicator-sound-servicekp 2047 1 0 09:44 ? 00:00:00 /usr/lib/x86_64-linux-gnu/indicator-application-servicekp 2063 1 0 09:44 ? 00:00:00 /usr/lib/evolution/evolution-source-registrykp 2084 1 0 09:44 ? 00:00:00 /usr/lib/geoclue/geoclue-masterkp 2096 1 0 09:44 ? 00:00:00 /usr/lib/ubuntu-geoip/ubuntu-geoip-providerkp 2124 1 0 09:45 ? 00:00:00 /usr/lib/libunity-webapps/unity-webapps-servicekp 2142 1 0 09:45 ? 00:00:00 /usr/lib/unity-lens-applications/unity-applications-daemonkp 2149 1 0 09:45 ? 00:00:00 /usr/lib/gwibber/unity-gwibber-daemonkp 2150 1 0 09:45 ? 00:00:00 /usr/lib/x86_64-linux-gnu/unity-music-daemonkp 2151 1 0 09:45 ? 00:00:00 /usr/bin/python3 /usr/lib/unity-lens-photos/unity-lens-photoskp 2152 1 0 09:45 ? 00:00:00 /usr/lib/x86_64-linux-gnu/unity-shopping-daemonkp 2153 1 0 09:45 ? 00:00:00 /usr/lib/unity-lens-files/unity-files-daemonkp 2154 1 0 09:45 ? 00:00:00 /usr/bin/python /usr/lib/unity-lens-video/unity-lens-videokp 2202 1 0 09:45 ? 00:00:00 /usr/bin/zeitgeist-daemonkp 2214 1 0 09:45 ? 00:00:00 /usr/lib/zeitgeist/zeitgeist-ftskp 2216 1 0 09:45 ? 00:00:00 zeitgeist-datahubkp 2222 2214 0 09:45 ? 00:00:00 /bin/catkp 2235 1 0 09:45 ? 00:00:00 /usr/lib/x86_64-linux-gnu/unity-musicstore-daemonkp 2237 1 0 09:45 ? 00:00:00 /usr/bin/python3 /usr/lib/unity-lens-files/unity-scope-gdocskp 2259 1 0 09:45 ? 00:00:00 /usr/bin/python /usr/lib/unity-scope-video-remote/unity-scope-video-remotekp 2273 1839 0 09:45 ? 00:00:00 telepathy-indicatorkp 2280 1 0 09:45 ? 00:00:00 /usr/lib/telepathy/mission-control-5kp 2286 1 0 09:45 ? 00:00:00 /usr/bin/signon-uikp 2315 1 0 09:45 ? 00:00:00 /usr/bin/python /usr/lib/ubuntuone-client/ubuntuone-syncdaemon

Page 10: Linux Practice

root 2355 1 0 09:45 ? 00:00:02 /sbin/mount.ntfs /dev/sda6 /media/kp/01CDF88B2E46B1E0 -o rw,nosuid,nodev,uhelper=udisks2,uid=1000,gid=1000,dmask=0077,fmask=0177kp 2366 1 0 09:45 ? 00:00:00 /usr/lib/gvfs/gvfsd-metadatakp 2372 1839 0 09:45 ? 00:00:01 update-notifierkp 2426 1 0 09:45 ? 00:00:02 /usr/lib/notify-osd/notify-osdkp 2431 1 0 09:45 ? 00:00:00 /usr/bin/gnome-screensaver --no-daemonkp 2473 1839 0 09:46 ? 00:00:00 /usr/lib/x86_64-linux-gnu/deja-dup/deja-dup-monitorkp 2585 1 0 09:48 ? 00:00:53 gnome-terminalkp 2589 2585 0 09:48 ? 00:00:00 gnome-pty-helperkp 2590 2585 0 09:48 pts/0 00:00:00 bashkp 2928 1 0 10:03 ? 00:00:06 evince /media/kp/01CDF88B2E46B1E0/EiTRA/Latest Linux_assignment_.pdfkp 2934 1 0 10:03 ? 00:00:00 /usr/lib/evince/evincedkp 3037 1 0 10:05 ? 00:00:00 /usr/lib/libreoffice/program/oosplash --writer /media/kp/01CDF88B2E46B1E0/EiTRA/Solved/a4.docxkp 3058 3037 0 10:05 ? 00:00:41 /usr/lib/libreoffice/program/soffice.bin --writer /media/kp/01CDF88B2E46B1E0/EiTRA/Solved/a4.docx --splash-pipe=6kp 4002 2585 0 11:13 pts/1 00:00:00 bashkp 4091 4002 0 11:20 pts/1 00:00:01 topkp 4092 4002 0 11:21 pts/1 00:00:00 topkp 4094 4002 0 11:21 pts/1 00:00:00 topkp 4647 1 0 11:27 ? 00:00:01 /usr/bin/python /usr/share/oneconf/oneconf-servicekp 4679 4002 0 11:31 pts/1 00:00:00 ps -faekp 4680 4002 0 11:31 pts/1 00:00:00 grep --color=auto kpkp@ubuntu:~$ clear

kp@ubuntu:~$ ps -fae | grep kproot 634 2 0 09:44 ? 00:00:00 [kpsmoused]kp 1828 1 0 09:44 ? 00:00:00 /usr/bin/gnome-keyring-daemon --daemonize --loginkp 1839 1489 0 09:44 ? 00:00:00 gnome-session --session=ubuntukp 1874 1839 0 09:44 ? 00:00:00 /usr/bin/ssh-agent /usr/bin/dbus-launch --exit-with-session gnome-session --session=ubuntukp 1877 1 0 09:44 ? 00:00:00 /usr/bin/dbus-launch --exit-with-session gnome-session --session=ubuntukp 1878 1 0 09:44 ? 00:00:02 //bin/dbus-daemon --fork --print-pid 5 --print-address 7 --sessionkp 1880 1 0 09:44 ? 00:00:00 /usr/lib/at-spi2-core/at-spi-bus-launcherkp 1884 1880 0 09:44 ? 00:00:00 /bin/dbus-daemon --config-file=/etc/at-spi2/accessibility.conf --nofork --print-address 3kp 1887 1 0 09:44 ? 00:00:00 /usr/lib/at-spi2-core/at-spi2-registryd --use-gnome-sessionkp 1898 1839 0 09:44 ? 00:00:03 /usr/lib/gnome-settings-daemon/gnome-settings-daemonkp 1906 1 0 09:44 ? 00:00:00 /usr/lib/gvfs/gvfsdkp 1910 1 0 09:44 ? 00:00:00 /usr/lib/gvfs//gvfsd-fuse -f /run/user/kp/gvfskp 1919 1839 1 09:44 ? 00:02:08 compizkp 1925 1 0 09:44 ? 00:00:00 /usr/lib/dconf/dconf-servicekp 1930 1839 0 09:44 ? 00:00:00 /usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1kp 1932 1839 0 09:44 ? 00:00:00 /usr/lib/gnome-settings-daemon/gnome-fallback-mount-helper

Page 11: Linux Practice

kp 1933 1839 0 09:44 ? 00:00:04 nm-appletkp 1934 1839 0 09:44 ? 00:00:00 bluetooth-appletkp 1939 1839 0 09:44 ? 00:00:06 nautilus -nkp 1950 1 0 09:44 ? 00:00:00 /usr/lib/gvfs/gvfs-udisks2-volume-monitorkp 1969 1898 0 09:44 ? 00:00:03 syndaemon -i 2.0 -K -R -tkp 1974 1 0 09:44 ? 00:00:00 /usr/bin/pulseaudio --start --log-target=syslogkp 1977 1 0 09:44 ? 00:00:00 /usr/lib/gvfs/gvfs-afc-volume-monitorkp 1982 1 0 09:44 ? 00:00:00 /usr/lib/gvfs/gvfs-gphoto2-volume-monitorkp 1988 1 0 09:44 ? 00:00:00 /usr/lib/x86_64-linux-gnu/gconf/gconfd-2kp 1991 1 0 09:44 ? 00:00:02 /usr/lib/bamf/bamfdaemonkp 1996 1 0 09:44 ? 00:00:00 /usr/lib/gvfs/gvfsd-trash --spawner :1.7 /org/gtk/gvfs/exec_spaw/0kp 2001 1919 0 09:44 ? 00:00:00 /bin/sh -c /usr/bin/gtk-window-decoratorkp 2002 2001 0 09:44 ? 00:00:02 /usr/bin/gtk-window-decoratorkp 2009 1974 0 09:44 ? 00:00:00 /usr/lib/pulseaudio/pulse/gconf-helperkp 2011 1 0 09:44 ? 00:00:00 /usr/lib/gvfs/gvfsd-burn --spawner :1.7 /org/gtk/gvfs/exec_spaw/1kp 2016 1 0 09:44 ? 00:00:11 /usr/lib/unity/unity-panel-servicekp 2018 1 0 09:44 ? 00:00:05 /usr/lib/indicator-appmenu/hud-servicekp 2031 1 0 09:44 ? 00:00:00 /usr/lib/indicator-session/indicator-session-servicekp 2033 1 0 09:44 ? 00:00:00 /usr/lib/indicator-printers/indicator-printers-servicekp 2036 1 0 09:44 ? 00:00:00 /usr/lib/indicator-messages/indicator-messages-servicekp 2037 1 0 09:44 ? 00:00:00 /usr/lib/indicator-datetime/indicator-datetime-servicekp 2046 1 0 09:44 ? 00:00:00 /usr/lib/indicator-sound/indicator-sound-servicekp 2047 1 0 09:44 ? 00:00:00 /usr/lib/x86_64-linux-gnu/indicator-application-servicekp 2063 1 0 09:44 ? 00:00:00 /usr/lib/evolution/evolution-source-registrykp 2084 1 0 09:44 ? 00:00:00 /usr/lib/geoclue/geoclue-masterkp 2096 1 0 09:44 ? 00:00:00 /usr/lib/ubuntu-geoip/ubuntu-geoip-providerkp 2124 1 0 09:45 ? 00:00:00 /usr/lib/libunity-webapps/unity-webapps-servicekp 2142 1 0 09:45 ? 00:00:00 /usr/lib/unity-lens-applications/unity-applications-daemonkp 2149 1 0 09:45 ? 00:00:00 /usr/lib/gwibber/unity-gwibber-daemonkp 2150 1 0 09:45 ? 00:00:00 /usr/lib/x86_64-linux-gnu/unity-music-daemonkp 2151 1 0 09:45 ? 00:00:00 /usr/bin/python3 /usr/lib/unity-lens-photos/unity-lens-photoskp 2152 1 0 09:45 ? 00:00:00 /usr/lib/x86_64-linux-gnu/unity-shopping-daemonkp 2153 1 0 09:45 ? 00:00:00 /usr/lib/unity-lens-files/unity-files-daemonkp 2154 1 0 09:45 ? 00:00:00 /usr/bin/python /usr/lib/unity-lens-video/unity-lens-videokp 2202 1 0 09:45 ? 00:00:00 /usr/bin/zeitgeist-daemonkp 2214 1 0 09:45 ? 00:00:00 /usr/lib/zeitgeist/zeitgeist-ftskp 2216 1 0 09:45 ? 00:00:00 zeitgeist-datahubkp 2222 2214 0 09:45 ? 00:00:00 /bin/catkp 2235 1 0 09:45 ? 00:00:00 /usr/lib/x86_64-linux-gnu/unity-musicstore-daemonkp 2237 1 0 09:45 ? 00:00:00 /usr/bin/python3 /usr/lib/unity-lens-files/unity-scope-gdocskp 2259 1 0 09:45 ? 00:00:00 /usr/bin/python /usr/lib/unity-scope-video-remote/unity-scope-video-remotekp 2273 1839 0 09:45 ? 00:00:00 telepathy-indicatorkp 2280 1 0 09:45 ? 00:00:00 /usr/lib/telepathy/mission-control-5kp 2286 1 0 09:45 ? 00:00:00 /usr/bin/signon-uikp 2315 1 0 09:45 ? 00:00:00 /usr/bin/python /usr/lib/ubuntuone-client/ubuntuone-syncdaemon

Page 12: Linux Practice

root 2355 1 0 09:45 ? 00:00:02 /sbin/mount.ntfs /dev/sda6 /media/kp/01CDF88B2E46B1E0 -o rw,nosuid,nodev,uhelper=udisks2,uid=1000,gid=1000,dmask=0077,fmask=0177kp 2366 1 0 09:45 ? 00:00:00 /usr/lib/gvfs/gvfsd-metadatakp 2372 1839 0 09:45 ? 00:00:01 update-notifierkp 2426 1 0 09:45 ? 00:00:02 /usr/lib/notify-osd/notify-osdkp 2431 1 0 09:45 ? 00:00:00 /usr/bin/gnome-screensaver --no-daemonkp 2473 1839 0 09:46 ? 00:00:00 /usr/lib/x86_64-linux-gnu/deja-dup/deja-dup-monitorkp 2585 1 0 09:48 ? 00:00:53 gnome-terminalkp 2589 2585 0 09:48 ? 00:00:00 gnome-pty-helperkp 2590 2585 0 09:48 pts/0 00:00:00 bashkp 2928 1 0 10:03 ? 00:00:06 evince /media/kp/01CDF88B2E46B1E0/EiTRA/Latest Linux_assignment_.pdfkp 2934 1 0 10:03 ? 00:00:00 /usr/lib/evince/evincedkp 3037 1 0 10:05 ? 00:00:00 /usr/lib/libreoffice/program/oosplash --writer /media/kp/01CDF88B2E46B1E0/EiTRA/Solved/a4.docxkp 3058 3037 0 10:05 ? 00:00:43 /usr/lib/libreoffice/program/soffice.bin --writer /media/kp/01CDF88B2E46B1E0/EiTRA/Solved/a4.docx --splash-pipe=6kp 4002 2585 0 11:13 pts/1 00:00:00 bashkp 4091 4002 0 11:20 pts/1 00:00:01 topkp 4092 4002 0 11:21 pts/1 00:00:00 topkp 4094 4002 0 11:21 pts/1 00:00:00 topkp 4647 1 0 11:27 ? 00:00:01 /usr/bin/python /usr/share/oneconf/oneconf-servicekp 4684 4002 0 11:33 pts/1 00:00:00 ps -faekp 4685 4002 0 11:33 pts/1 00:00:00 grep --color=auto kp

11. Start a sleep 300 process running in the background. Log off the server, and log back in again. List all the processes that you are running. What happened to your sleep process? Now repeat, except this time start by running nohup sleep 300.

>When we execute the command sleep 300 and relog-in to machine,process sleep was already terminated.>When we execute the command nohup sleep 300 and relog-in to machine,process sleep is still running. 12. Multiple jobs can be issued from the same command line using the operators ;, && and ||. Try combining the commands cat nonexistent and echo hello using each of these operators. Reverse the order of the commands and try again. What are the rules about when the commands will be executed?

kp@ubuntu:~$ cat kishan || echo hellohihellogood afternoon

kp@ubuntu:~$ cat kishan && echo hellohihellogood afternoonhello

Page 13: Linux Practice

kp@ubuntu:~$ cat kishan ; echo hellohihellogood afternoonhello

kp@ubuntu:~$ error ; echo helloNo command 'error' found, did you mean: Command 'perror' from package 'mysql-server-5.5' (main)error: command not foundhello

kp@ubuntu:~$ error && echo helloNo command 'error' found, did you mean: Command 'perror' from package 'mysql-server-5.5' (main)error: command not found

kp@ubuntu:~$ error || echo helloNo command 'error' found, did you mean: Command 'perror' from package 'mysql-server-5.5' (main)error: command not foundhello

kp@ubuntu:~$ cat kishan && errorhihellogood afternoonNo command 'error' found, did you mean: Command 'perror' from package 'mysql-server-5.5' (main)error: command not found

kp@ubuntu:~$ cat kishan || errorhihellogood afternoon

kp@ubuntu:~$ cat kishan ; errorhihellogood afternoonNo command 'error' found, did you mean: Command 'perror' from package 'mysql-server-5.5' (main)error: command not found

kp@ubuntu:~$ cat kishan && echo hello && cat kishanhihellogood afternoonhello

Page 14: Linux Practice

hihellogood afternoon

13. What does the xargs command do? Can you combine it with find and grep to find yet another way of searching all files in the /home subdirectory tree for the word hello?

14. What does the cut command do? Can you use it together with w to produce a list of login names and CPU times corresponding to each active process? Can you now (all on the same command line) use sort and head or tail to find the user whose process is using the most CPU?

>cut - remove sections from each line of files

>