Linux Environment and Tools
Linux Environment and Tools
Subendu Santra
[email protected]
May 2023
History
● https://eylenburg.github.io/os_familytree.htm
● https://upload.wikimedia.org/wikipedia/comm
ons/7/77/Unix_history-simple.svg
● GNU coreutils
Linux
● Linux kernel (Linus Torvald) and GNU Project
(Richard Stallman)
● True UNIX vs UNIX like – Open Group Consortium.
● Linux distribution = GNU/Linux Kernel + GNU tools
+ Documentation + package manager + Window
system + desktop environment
● 1000’s of Distros available - RedHat, Ubuntu,
Fedora, Debian etc
Lets setup passwordless ssh…
Source Machine Destination Machine
Interface to an OS
Takes user commands and hands them over to the
OS to execute
Terminal
cd cp wc df fg alias chown
find /path [args] -exec [cmd] {} \+ for all found results, the command cmd is executed with all the found results.
cmd result1 result2 … result N
find /tmp/ -type f -mtime +10 -exec ls -l {} \; List files older than 10 days in /tmp directory
find /tmp/ -type f -mtime +10 -exec rm -rf {} \; To remove files older than 10 days in /tmp directory
find / -type f -name ‘howtouselinux*’ -exec mv {} {}_renamed \; The files are renamed with _renamed extension
find /tmp/dir1/ -type f -exec chown root:root {} \; -exec chmod Each consecutive -exec command is executed only if
o+x {} \; the previous ones returned true (i.e. 0 exit status of the
commands).
awk (Aho, Weinberger & Kernighan)
SYNTAX: awk 'pattern{action}' file
Skip first line and print first field of other lines awk 'NR!=1{print $1}' file
awk special variable FS and OFS awk 'NR!=1{print $1,$3}' FS=”,” OFS="," file
sed (Stream EDitor)
Append to the beginning s/^/Fruit: /
● rpm ● yum
○ rpm -qa ○ yum repolist
○ rpm -qi ○ yum install
○ rpm -qf ○ yum remove
○ yum reinstall
○ rpm -ql
○ yum update
○ rpm -q --requires |
--provides
Exercises
1. Count the number of lines, words and characters in a file. Get hold of a .c
file and count the number of for loops in it.
2. List all the files with a given pattern and check if a word is present in any of
them
3. Check the current disk usage.
4. List all processes running on the system. Can you identify process ID and
parent process ID.
5. Create a .tar file. List the contents of a .tar file without extracting it.
Thank you