<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.itcollege.ee/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Srugam</id>
	<title>ICO wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.itcollege.ee/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Srugam"/>
	<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php/Special:Contributions/Srugam"/>
	<updated>2026-05-10T00:01:52Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121309</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121309"/>
		<updated>2017-05-07T15:40:00Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Bash scripts */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
It is a powerful shell, and features, among other things:&lt;br /&gt;
&lt;br /&gt;
**Command line editing&lt;br /&gt;
**Command history&lt;br /&gt;
**A directory stack (pushd, popd)&lt;br /&gt;
**Command substitution&lt;br /&gt;
**Special variables, like $PPID&lt;br /&gt;
**Autocompletion&lt;br /&gt;
**In-process integer arithmetic: $((...))&lt;br /&gt;
**In-process regexes&lt;br /&gt;
**Aliases&lt;br /&gt;
**Functions&lt;br /&gt;
**Arrays&lt;br /&gt;
**Expansions: tilde, brace, variable&lt;br /&gt;
**Substring awesomeness&lt;br /&gt;
**Conditional expressions&lt;br /&gt;
**Security (restricted shell mode)&lt;br /&gt;
**Job Control&lt;br /&gt;
**Timing&lt;br /&gt;
**Prompt customization&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Using Bash for administrating=&lt;br /&gt;
==Useful commands==&lt;br /&gt;
===Command: find===&lt;br /&gt;
Search for files in the given directory, hierarchically starting at the parent directory and moving to sub-directories.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# find -name *.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: grep===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep user /etc/passwd &lt;br /&gt;
user:x:1000:1000:user,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Ignore word case and all other combination with ‘-i‘ option.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -i USER /etc/passwd &lt;br /&gt;
user:x:1000:1000:User,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Search recursively (-r) i.e. read all files under each directory for a string “127.0.0.1“.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -r &amp;quot;127.0.0.1&amp;quot; /etc/ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: man===&lt;br /&gt;
The ‘man‘ is the system’s manual pager. Man provides online documentation for all the possible options with a command and its usages. Almost all the command comes with their corresponding manual pages. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# man bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Manual page for man page itself, similarly ‘man cat‘ (Manual page for cat command) and ‘man ls‘ (Manual page for command ls).&lt;br /&gt;
&lt;br /&gt;
===Command: ps===&lt;br /&gt;
ps (Process) gives the status of running processes with a unique Id called PID.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
To list status of all the processes along with process id and PID, use option ‘-A‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: This command is very useful when you want to know which processes are running or may need PID sometimes, for process to be killed. You can use it with ‘grep‘ command to find customised output. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i ssh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Here ‘ps‘ is pipelined with ‘grep‘ command to find customised and relevant output of our need.&lt;br /&gt;
&lt;br /&gt;
===Command: kill===&lt;br /&gt;
You need a process’s pid (ps) to kill it.&lt;br /&gt;
Let suppose you want to kill program ‘apache2‘ that might not be responding. Run ‘ps -A‘ along with grep command.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i apache2&lt;br /&gt;
1285 ?        00:00:00 apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Find process ‘apache2‘, note its pid and kill it. For example, in that case ‘apache2‘ pid is ‘1285‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# kill 1285 (to kill the process apache2)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Every time you re-run a process or start a system, a new pid is generated for each process and you can know about the current running processes and its pid using command ‘ps‘.&lt;br /&gt;
Another way to kill the same process is.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# pkill apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Kill requires job id / process id for sending signals, where as in pkill, you have an option of using pattern, specifying process owner, etc.&lt;br /&gt;
&lt;br /&gt;
===Command: whereis===&lt;br /&gt;
The ‘whereis‘ command is used to locate the Binary, Sources and Manual Pages of the command. For example, to locate the Binary, Sources and Manual Pages of the command ‘ls‘ and ‘kill‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# whereis ls &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# whereis kill&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: This is useful to know where the binaries are installed for manual editing sometimes.&lt;br /&gt;
&lt;br /&gt;
===Command: service===&lt;br /&gt;
The ‘service‘ command controls the Starting, Stopping or Restarting of a ‘service‘. This command make it possible to start, restart or stop a service without restarting the system, for the changes to be taken into effect.&lt;br /&gt;
&lt;br /&gt;
Startting an apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# service apache2 start&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restarting a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# service apache2 restart&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stopping a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Stopping a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: All the process script lies in ‘/etc/init.d‘, and the path might needs to be included on certain system, i.e., in spite of running “service apache2 start” you would be asked to run “/etc/init.d/apache2 start”.&lt;br /&gt;
&lt;br /&gt;
===Command: alias===&lt;br /&gt;
alias is a built in shell command that lets you assign name for a long command or frequently used command.&lt;br /&gt;
For example.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
alias root=&#039;sudo -i&#039;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Command: df===&lt;br /&gt;
Report disk usages of file system. Useful for user as well as System Administrator to keep track of their disk usages. ‘df‘ works by examining directory entries, which generally are updated only when a file is closed.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# df&lt;br /&gt;
Filesystem     1K-blocks    Used Available Use% Mounted on&lt;br /&gt;
/dev/sda1       47929224 7811908  37675948  18% /&lt;br /&gt;
none                   4       0         4   0% /sys/fs/cgroup&lt;br /&gt;
udev             1005916       4   1005912   1% /dev&lt;br /&gt;
tmpfs             202824     816    202008   1% /run&lt;br /&gt;
none                5120       0      5120   0% /run/lock&lt;br /&gt;
none             1014120     628   1013492   1% /run/shm&lt;br /&gt;
none              102400      44    102356   1% /run/user&lt;br /&gt;
/dev/sda5         184307   79852     94727  46% /boot&lt;br /&gt;
/dev/sda7       95989516   61104  91045676   1% /data&lt;br /&gt;
/dev/sda8       91953192   57032  87218528   1% /personal&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Command: du===&lt;br /&gt;
Estimate file space usage. Output the summary of disk usages by ever file hierarchically, i.e., in recursive manner.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# du&lt;br /&gt;
308   ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/icons&lt;br /&gt;
344   ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop&lt;br /&gt;
4     ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/applet&lt;br /&gt;
548   ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/oblique-fonts&lt;br /&gt;
2048  ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/fonts&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: ‘df‘ only reports usage statistics on file systems, while ‘du‘, on the other hand, measures directory contents.&lt;br /&gt;
==Bash scripts==&lt;br /&gt;
===Cpu monitoring===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
while [ true ] ;do&lt;br /&gt;
used=`free -m |awk &#039;NR==3 {print $4}&#039;`&lt;br /&gt;
&lt;br /&gt;
if [ $used -lt 1000 ] &amp;amp;&amp;amp; [ $used -gt 800 ]; then&lt;br /&gt;
echo &amp;quot;Free memory is below 1000MB. Possible memory leak!!!&amp;quot; | /bin/mail -s &amp;quot;HIGH MEMORY ALERT!!!&amp;quot; user@itcollege.ee&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
fi&lt;br /&gt;
sleep 5&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
===Adding new users to a Linux system===&lt;br /&gt;
This script allows the root user or admin to add new users to the system in an easier way by just typing the user name and password (The password is entered in an encrypted manner).&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
# Script to add a user to Linux system&lt;br /&gt;
if [ $(id -u) -eq 0 ]; then&lt;br /&gt;
    read -p &amp;quot;Enter username : &amp;quot; username&lt;br /&gt;
    read -s -p &amp;quot;Enter password : &amp;quot; password&lt;br /&gt;
    egrep &amp;quot;^$username&amp;quot; /etc/passwd &amp;gt;/dev/null&lt;br /&gt;
    if [ $? -eq 0 ]; then&lt;br /&gt;
        echo &amp;quot;$username exists!&amp;quot;&lt;br /&gt;
        exit 1&lt;br /&gt;
    else&lt;br /&gt;
        pass=$(perl -e &#039;print crypt($ARGV[0], &amp;quot;password&amp;quot;)&#039; $password)&lt;br /&gt;
        useradd -m -p $pass $username&lt;br /&gt;
        [ $? -eq 0 ] &amp;amp;&amp;amp; echo &amp;quot;User has been added to system!&amp;quot; || echo &amp;quot;Failed to add a user!&amp;quot;&lt;br /&gt;
    fi&lt;br /&gt;
else&lt;br /&gt;
    echo &amp;quot;Only root may add a user to the system&amp;quot;&lt;br /&gt;
    exit 2&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
===Login Script===&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo su student2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if u run:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash --login&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if you login to a machine via ssh e.g:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@machine&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll be invoking ~/.profile Note that ~/.profile (or if not there, one of ~/.bash_profile or ~/.bash_login) normally contains relevant commands to run another script called ~/.bashrc (if said file exists):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if [ -f ~/.bashrc ]; then&lt;br /&gt;
    . ~/.bashrc&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Checking Server Utilization===&lt;br /&gt;
Checking the server utilization is one of the important task of an administrator, and a good administrator is one who knows how to automate his day to day task. Below is the script that will give many such information about your server&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
date;&lt;br /&gt;
echo &amp;quot;uptime:&amp;quot;&lt;br /&gt;
uptime&lt;br /&gt;
echo &amp;quot;Currently connected:&amp;quot;&lt;br /&gt;
w&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;Last logins:&amp;quot;&lt;br /&gt;
last -a |head -3&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;Disk and memory usage:&amp;quot;&lt;br /&gt;
df -h | xargs | awk &#039;{print &amp;quot;Free/total disk: &amp;quot; $11 &amp;quot; / &amp;quot; $9}&#039;&lt;br /&gt;
free -m | xargs | awk &#039;{print &amp;quot;Free/total memory: &amp;quot; $17 &amp;quot; / &amp;quot; $8 &amp;quot; MB&amp;quot;}&#039;&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
start_log=`head -1 /var/log/messages |cut -c 1-12`&lt;br /&gt;
oom=`grep -ci kill /var/log/messages`&lt;br /&gt;
echo -n &amp;quot;OOM errors since $start_log :&amp;quot; $oom&lt;br /&gt;
echo &amp;quot;&amp;quot;&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;Utilization and most expensive processes:&amp;quot;&lt;br /&gt;
top -b |head -3&lt;br /&gt;
echo&lt;br /&gt;
top -b |head -10 |tail -4&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;Open TCP ports:&amp;quot;&lt;br /&gt;
nmap -p- -T4 127.0.0.1&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;Current connections:&amp;quot;&lt;br /&gt;
ss -s&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;processes:&amp;quot;&lt;br /&gt;
ps auxf --width=200&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;vmstat:&amp;quot;&lt;br /&gt;
vmstat 1 5&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Checking disk space + alert===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
MAX=95&lt;br /&gt;
EMAIL=user@itcollege.ee&lt;br /&gt;
PART=sda1&lt;br /&gt;
USE=`df -h |grep $PART | awk &#039;{ print $5 }&#039; | cut -d&#039;%&#039; -f1`&lt;br /&gt;
if [ $USE -gt $MAX ]; then&lt;br /&gt;
echo &amp;quot;Percent used: $USE&amp;quot; | mail -s &amp;quot;Running out of disk space&amp;quot; $EMAIL&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
https://www.tecmint.com&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121307</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121307"/>
		<updated>2017-05-07T15:37:15Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
It is a powerful shell, and features, among other things:&lt;br /&gt;
&lt;br /&gt;
**Command line editing&lt;br /&gt;
**Command history&lt;br /&gt;
**A directory stack (pushd, popd)&lt;br /&gt;
**Command substitution&lt;br /&gt;
**Special variables, like $PPID&lt;br /&gt;
**Autocompletion&lt;br /&gt;
**In-process integer arithmetic: $((...))&lt;br /&gt;
**In-process regexes&lt;br /&gt;
**Aliases&lt;br /&gt;
**Functions&lt;br /&gt;
**Arrays&lt;br /&gt;
**Expansions: tilde, brace, variable&lt;br /&gt;
**Substring awesomeness&lt;br /&gt;
**Conditional expressions&lt;br /&gt;
**Security (restricted shell mode)&lt;br /&gt;
**Job Control&lt;br /&gt;
**Timing&lt;br /&gt;
**Prompt customization&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Using Bash for administrating=&lt;br /&gt;
==Useful commands==&lt;br /&gt;
===Command: find===&lt;br /&gt;
Search for files in the given directory, hierarchically starting at the parent directory and moving to sub-directories.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# find -name *.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: grep===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep user /etc/passwd &lt;br /&gt;
user:x:1000:1000:user,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Ignore word case and all other combination with ‘-i‘ option.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -i USER /etc/passwd &lt;br /&gt;
user:x:1000:1000:User,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Search recursively (-r) i.e. read all files under each directory for a string “127.0.0.1“.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -r &amp;quot;127.0.0.1&amp;quot; /etc/ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: man===&lt;br /&gt;
The ‘man‘ is the system’s manual pager. Man provides online documentation for all the possible options with a command and its usages. Almost all the command comes with their corresponding manual pages. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# man bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Manual page for man page itself, similarly ‘man cat‘ (Manual page for cat command) and ‘man ls‘ (Manual page for command ls).&lt;br /&gt;
&lt;br /&gt;
===Command: ps===&lt;br /&gt;
ps (Process) gives the status of running processes with a unique Id called PID.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
To list status of all the processes along with process id and PID, use option ‘-A‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: This command is very useful when you want to know which processes are running or may need PID sometimes, for process to be killed. You can use it with ‘grep‘ command to find customised output. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i ssh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Here ‘ps‘ is pipelined with ‘grep‘ command to find customised and relevant output of our need.&lt;br /&gt;
&lt;br /&gt;
===Command: kill===&lt;br /&gt;
You need a process’s pid (ps) to kill it.&lt;br /&gt;
Let suppose you want to kill program ‘apache2‘ that might not be responding. Run ‘ps -A‘ along with grep command.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i apache2&lt;br /&gt;
1285 ?        00:00:00 apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Find process ‘apache2‘, note its pid and kill it. For example, in that case ‘apache2‘ pid is ‘1285‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# kill 1285 (to kill the process apache2)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Every time you re-run a process or start a system, a new pid is generated for each process and you can know about the current running processes and its pid using command ‘ps‘.&lt;br /&gt;
Another way to kill the same process is.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# pkill apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Kill requires job id / process id for sending signals, where as in pkill, you have an option of using pattern, specifying process owner, etc.&lt;br /&gt;
&lt;br /&gt;
===Command: whereis===&lt;br /&gt;
The ‘whereis‘ command is used to locate the Binary, Sources and Manual Pages of the command. For example, to locate the Binary, Sources and Manual Pages of the command ‘ls‘ and ‘kill‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# whereis ls &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# whereis kill&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: This is useful to know where the binaries are installed for manual editing sometimes.&lt;br /&gt;
&lt;br /&gt;
===Command: service===&lt;br /&gt;
The ‘service‘ command controls the Starting, Stopping or Restarting of a ‘service‘. This command make it possible to start, restart or stop a service without restarting the system, for the changes to be taken into effect.&lt;br /&gt;
&lt;br /&gt;
Startting an apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# service apache2 start&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restarting a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# service apache2 restart&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stopping a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Stopping a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: All the process script lies in ‘/etc/init.d‘, and the path might needs to be included on certain system, i.e., in spite of running “service apache2 start” you would be asked to run “/etc/init.d/apache2 start”.&lt;br /&gt;
&lt;br /&gt;
===Command: alias===&lt;br /&gt;
alias is a built in shell command that lets you assign name for a long command or frequently used command.&lt;br /&gt;
For example.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
alias root=&#039;sudo -i&#039;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Command: df===&lt;br /&gt;
Report disk usages of file system. Useful for user as well as System Administrator to keep track of their disk usages. ‘df‘ works by examining directory entries, which generally are updated only when a file is closed.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# df&lt;br /&gt;
Filesystem     1K-blocks    Used Available Use% Mounted on&lt;br /&gt;
/dev/sda1       47929224 7811908  37675948  18% /&lt;br /&gt;
none                   4       0         4   0% /sys/fs/cgroup&lt;br /&gt;
udev             1005916       4   1005912   1% /dev&lt;br /&gt;
tmpfs             202824     816    202008   1% /run&lt;br /&gt;
none                5120       0      5120   0% /run/lock&lt;br /&gt;
none             1014120     628   1013492   1% /run/shm&lt;br /&gt;
none              102400      44    102356   1% /run/user&lt;br /&gt;
/dev/sda5         184307   79852     94727  46% /boot&lt;br /&gt;
/dev/sda7       95989516   61104  91045676   1% /data&lt;br /&gt;
/dev/sda8       91953192   57032  87218528   1% /personal&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Command: du===&lt;br /&gt;
Estimate file space usage. Output the summary of disk usages by ever file hierarchically, i.e., in recursive manner.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# du&lt;br /&gt;
308   ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/icons&lt;br /&gt;
344   ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop&lt;br /&gt;
4     ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/applet&lt;br /&gt;
548   ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/oblique-fonts&lt;br /&gt;
2048  ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/fonts&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: ‘df‘ only reports usage statistics on file systems, while ‘du‘, on the other hand, measures directory contents.&lt;br /&gt;
==Bash scripts==&lt;br /&gt;
===Cpu monitoring===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
while [ true ] ;do&lt;br /&gt;
used=`free -m |awk &#039;NR==3 {print $4}&#039;`&lt;br /&gt;
&lt;br /&gt;
if [ $used -lt 1000 ] &amp;amp;&amp;amp; [ $used -gt 800 ]; then&lt;br /&gt;
echo &amp;quot;Free memory is below 1000MB. Possible memory leak!!!&amp;quot; | /bin/mail -s &amp;quot;HIGH MEMORY ALERT!!!&amp;quot; user@itcollege.ee&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
fi&lt;br /&gt;
sleep 5&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
===Adding new users to a Linux system===&lt;br /&gt;
This script allows the root user or admin to add new users to the system in an easier way by just typing the user name and password (The password is entered in an encrypted manner).&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
# Script to add a user to Linux system&lt;br /&gt;
if [ $(id -u) -eq 0 ]; then&lt;br /&gt;
    read -p &amp;quot;Enter username : &amp;quot; username&lt;br /&gt;
    read -s -p &amp;quot;Enter password : &amp;quot; password&lt;br /&gt;
    egrep &amp;quot;^$username&amp;quot; /etc/passwd &amp;gt;/dev/null&lt;br /&gt;
    if [ $? -eq 0 ]; then&lt;br /&gt;
        echo &amp;quot;$username exists!&amp;quot;&lt;br /&gt;
        exit 1&lt;br /&gt;
    else&lt;br /&gt;
        pass=$(perl -e &#039;print crypt($ARGV[0], &amp;quot;password&amp;quot;)&#039; $password)&lt;br /&gt;
        useradd -m -p $pass $username&lt;br /&gt;
        [ $? -eq 0 ] &amp;amp;&amp;amp; echo &amp;quot;User has been added to system!&amp;quot; || echo &amp;quot;Failed to add a user!&amp;quot;&lt;br /&gt;
    fi&lt;br /&gt;
else&lt;br /&gt;
    echo &amp;quot;Only root may add a user to the system&amp;quot;&lt;br /&gt;
    exit 2&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
===Login Script===&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo su student2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if u run:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash --login&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if you login to a machine via ssh e.g:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@machine&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll be invoking ~/.profile Note that ~/.profile (or if not there, one of ~/.bash_profile or ~/.bash_login) normally contains relevant commands to run another script called ~/.bashrc (if said file exists):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if [ -f ~/.bashrc ]; then&lt;br /&gt;
    . ~/.bashrc&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Checking Server Utilization===&lt;br /&gt;
Checking the server utilization is one of the important task of an administrator, and a good administrator is one who knows how to automate his day to day task. Below is the script that will give many such information about your server&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
date;&lt;br /&gt;
echo &amp;quot;uptime:&amp;quot;&lt;br /&gt;
uptime&lt;br /&gt;
echo &amp;quot;Currently connected:&amp;quot;&lt;br /&gt;
w&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;Last logins:&amp;quot;&lt;br /&gt;
last -a |head -3&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;Disk and memory usage:&amp;quot;&lt;br /&gt;
df -h | xargs | awk &#039;{print &amp;quot;Free/total disk: &amp;quot; $11 &amp;quot; / &amp;quot; $9}&#039;&lt;br /&gt;
free -m | xargs | awk &#039;{print &amp;quot;Free/total memory: &amp;quot; $17 &amp;quot; / &amp;quot; $8 &amp;quot; MB&amp;quot;}&#039;&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
start_log=`head -1 /var/log/messages |cut -c 1-12`&lt;br /&gt;
oom=`grep -ci kill /var/log/messages`&lt;br /&gt;
echo -n &amp;quot;OOM errors since $start_log :&amp;quot; $oom&lt;br /&gt;
echo &amp;quot;&amp;quot;&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;Utilization and most expensive processes:&amp;quot;&lt;br /&gt;
top -b |head -3&lt;br /&gt;
echo&lt;br /&gt;
top -b |head -10 |tail -4&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;Open TCP ports:&amp;quot;&lt;br /&gt;
nmap -p- -T4 127.0.0.1&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;Current connections:&amp;quot;&lt;br /&gt;
ss -s&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;processes:&amp;quot;&lt;br /&gt;
ps auxf --width=200&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;vmstat:&amp;quot;&lt;br /&gt;
vmstat 1 5&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
https://www.tecmint.com&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121306</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121306"/>
		<updated>2017-05-07T15:36:40Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Topics */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
It is a powerful shell, and features, among other things:&lt;br /&gt;
&lt;br /&gt;
**Command line editing&lt;br /&gt;
**Command history&lt;br /&gt;
**A directory stack (pushd, popd)&lt;br /&gt;
**Command substitution&lt;br /&gt;
**Special variables, like $PPID&lt;br /&gt;
**Autocompletion&lt;br /&gt;
**In-process integer arithmetic: $((...))&lt;br /&gt;
**In-process regexes&lt;br /&gt;
**Aliases&lt;br /&gt;
**Functions&lt;br /&gt;
**Arrays&lt;br /&gt;
**Expansions: tilde, brace, variable&lt;br /&gt;
**Substring awesomeness&lt;br /&gt;
**Conditional expressions&lt;br /&gt;
**Security (restricted shell mode)&lt;br /&gt;
**Job Control&lt;br /&gt;
**Timing&lt;br /&gt;
**Prompt customization&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Using Bash for administrating=&lt;br /&gt;
==Useful commands==&lt;br /&gt;
===Command: find===&lt;br /&gt;
Search for files in the given directory, hierarchically starting at the parent directory and moving to sub-directories.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# find -name *.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: grep===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep user /etc/passwd &lt;br /&gt;
user:x:1000:1000:user,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Ignore word case and all other combination with ‘-i‘ option.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -i USER /etc/passwd &lt;br /&gt;
user:x:1000:1000:User,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Search recursively (-r) i.e. read all files under each directory for a string “127.0.0.1“.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -r &amp;quot;127.0.0.1&amp;quot; /etc/ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: man===&lt;br /&gt;
The ‘man‘ is the system’s manual pager. Man provides online documentation for all the possible options with a command and its usages. Almost all the command comes with their corresponding manual pages. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# man bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Manual page for man page itself, similarly ‘man cat‘ (Manual page for cat command) and ‘man ls‘ (Manual page for command ls).&lt;br /&gt;
&lt;br /&gt;
===Command: ps===&lt;br /&gt;
ps (Process) gives the status of running processes with a unique Id called PID.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
To list status of all the processes along with process id and PID, use option ‘-A‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: This command is very useful when you want to know which processes are running or may need PID sometimes, for process to be killed. You can use it with ‘grep‘ command to find customised output. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i ssh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Here ‘ps‘ is pipelined with ‘grep‘ command to find customised and relevant output of our need.&lt;br /&gt;
&lt;br /&gt;
===Command: kill===&lt;br /&gt;
You need a process’s pid (ps) to kill it.&lt;br /&gt;
Let suppose you want to kill program ‘apache2‘ that might not be responding. Run ‘ps -A‘ along with grep command.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i apache2&lt;br /&gt;
1285 ?        00:00:00 apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Find process ‘apache2‘, note its pid and kill it. For example, in that case ‘apache2‘ pid is ‘1285‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# kill 1285 (to kill the process apache2)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Every time you re-run a process or start a system, a new pid is generated for each process and you can know about the current running processes and its pid using command ‘ps‘.&lt;br /&gt;
Another way to kill the same process is.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# pkill apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Kill requires job id / process id for sending signals, where as in pkill, you have an option of using pattern, specifying process owner, etc.&lt;br /&gt;
&lt;br /&gt;
===Command: whereis===&lt;br /&gt;
The ‘whereis‘ command is used to locate the Binary, Sources and Manual Pages of the command. For example, to locate the Binary, Sources and Manual Pages of the command ‘ls‘ and ‘kill‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# whereis ls &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# whereis kill&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: This is useful to know where the binaries are installed for manual editing sometimes.&lt;br /&gt;
&lt;br /&gt;
===Command: service===&lt;br /&gt;
The ‘service‘ command controls the Starting, Stopping or Restarting of a ‘service‘. This command make it possible to start, restart or stop a service without restarting the system, for the changes to be taken into effect.&lt;br /&gt;
&lt;br /&gt;
Startting an apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# service apache2 start&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restarting a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# service apache2 restart&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stopping a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Stopping a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: All the process script lies in ‘/etc/init.d‘, and the path might needs to be included on certain system, i.e., in spite of running “service apache2 start” you would be asked to run “/etc/init.d/apache2 start”.&lt;br /&gt;
&lt;br /&gt;
===Command: alias===&lt;br /&gt;
alias is a built in shell command that lets you assign name for a long command or frequently used command.&lt;br /&gt;
For example.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
alias root=&#039;sudo -i&#039;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Command: df===&lt;br /&gt;
Report disk usages of file system. Useful for user as well as System Administrator to keep track of their disk usages. ‘df‘ works by examining directory entries, which generally are updated only when a file is closed.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# df&lt;br /&gt;
Filesystem     1K-blocks    Used Available Use% Mounted on&lt;br /&gt;
/dev/sda1       47929224 7811908  37675948  18% /&lt;br /&gt;
none                   4       0         4   0% /sys/fs/cgroup&lt;br /&gt;
udev             1005916       4   1005912   1% /dev&lt;br /&gt;
tmpfs             202824     816    202008   1% /run&lt;br /&gt;
none                5120       0      5120   0% /run/lock&lt;br /&gt;
none             1014120     628   1013492   1% /run/shm&lt;br /&gt;
none              102400      44    102356   1% /run/user&lt;br /&gt;
/dev/sda5         184307   79852     94727  46% /boot&lt;br /&gt;
/dev/sda7       95989516   61104  91045676   1% /data&lt;br /&gt;
/dev/sda8       91953192   57032  87218528   1% /personal&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Command: du===&lt;br /&gt;
Estimate file space usage. Output the summary of disk usages by ever file hierarchically, i.e., in recursive manner.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# du&lt;br /&gt;
308   ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/icons&lt;br /&gt;
344   ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop&lt;br /&gt;
4     ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/applet&lt;br /&gt;
548   ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/oblique-fonts&lt;br /&gt;
2048  ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/fonts&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: ‘df‘ only reports usage statistics on file systems, while ‘du‘, on the other hand, measures directory contents.&lt;br /&gt;
==Bash scripts==&lt;br /&gt;
===Cpu monitoring===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
while [ true ] ;do&lt;br /&gt;
used=`free -m |awk &#039;NR==3 {print $4}&#039;`&lt;br /&gt;
&lt;br /&gt;
if [ $used -lt 1000 ] &amp;amp;&amp;amp; [ $used -gt 800 ]; then&lt;br /&gt;
echo &amp;quot;Free memory is below 1000MB. Possible memory leak!!!&amp;quot; | /bin/mail -s &amp;quot;HIGH MEMORY ALERT!!!&amp;quot; user@itcollege.ee&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
fi&lt;br /&gt;
sleep 5&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
===Adding new users to a Linux system===&lt;br /&gt;
This script allows the root user or admin to add new users to the system in an easier way by just typing the user name and password (The password is entered in an encrypted manner).&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
# Script to add a user to Linux system&lt;br /&gt;
if [ $(id -u) -eq 0 ]; then&lt;br /&gt;
    read -p &amp;quot;Enter username : &amp;quot; username&lt;br /&gt;
    read -s -p &amp;quot;Enter password : &amp;quot; password&lt;br /&gt;
    egrep &amp;quot;^$username&amp;quot; /etc/passwd &amp;gt;/dev/null&lt;br /&gt;
    if [ $? -eq 0 ]; then&lt;br /&gt;
        echo &amp;quot;$username exists!&amp;quot;&lt;br /&gt;
        exit 1&lt;br /&gt;
    else&lt;br /&gt;
        pass=$(perl -e &#039;print crypt($ARGV[0], &amp;quot;password&amp;quot;)&#039; $password)&lt;br /&gt;
        useradd -m -p $pass $username&lt;br /&gt;
        [ $? -eq 0 ] &amp;amp;&amp;amp; echo &amp;quot;User has been added to system!&amp;quot; || echo &amp;quot;Failed to add a user!&amp;quot;&lt;br /&gt;
    fi&lt;br /&gt;
else&lt;br /&gt;
    echo &amp;quot;Only root may add a user to the system&amp;quot;&lt;br /&gt;
    exit 2&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
===Login Script===&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo su student2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if u run:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash --login&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if you login to a machine via ssh e.g:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@machine&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll be invoking ~/.profile Note that ~/.profile (or if not there, one of ~/.bash_profile or ~/.bash_login) normally contains relevant commands to run another script called ~/.bashrc (if said file exists):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if [ -f ~/.bashrc ]; then&lt;br /&gt;
    . ~/.bashrc&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Checking Server Utilization===&lt;br /&gt;
Checking the server utilization is one of the important task of an administrator, and a good administrator is one who knows how to automate his day to day task. Below is the script that will give many such information about your server&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
date;&lt;br /&gt;
echo &amp;quot;uptime:&amp;quot;&lt;br /&gt;
uptime&lt;br /&gt;
echo &amp;quot;Currently connected:&amp;quot;&lt;br /&gt;
w&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;Last logins:&amp;quot;&lt;br /&gt;
last -a |head -3&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;Disk and memory usage:&amp;quot;&lt;br /&gt;
df -h | xargs | awk &#039;{print &amp;quot;Free/total disk: &amp;quot; $11 &amp;quot; / &amp;quot; $9}&#039;&lt;br /&gt;
free -m | xargs | awk &#039;{print &amp;quot;Free/total memory: &amp;quot; $17 &amp;quot; / &amp;quot; $8 &amp;quot; MB&amp;quot;}&#039;&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
start_log=`head -1 /var/log/messages |cut -c 1-12`&lt;br /&gt;
oom=`grep -ci kill /var/log/messages`&lt;br /&gt;
echo -n &amp;quot;OOM errors since $start_log :&amp;quot; $oom&lt;br /&gt;
echo &amp;quot;&amp;quot;&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;Utilization and most expensive processes:&amp;quot;&lt;br /&gt;
top -b |head -3&lt;br /&gt;
echo&lt;br /&gt;
top -b |head -10 |tail -4&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;Open TCP ports:&amp;quot;&lt;br /&gt;
nmap -p- -T4 127.0.0.1&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;Current connections:&amp;quot;&lt;br /&gt;
ss -s&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;processes:&amp;quot;&lt;br /&gt;
ps auxf --width=200&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;vmstat:&amp;quot;&lt;br /&gt;
vmstat 1 5&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121305</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121305"/>
		<updated>2017-05-07T15:36:31Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Example exercises */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
It is a powerful shell, and features, among other things:&lt;br /&gt;
&lt;br /&gt;
**Command line editing&lt;br /&gt;
**Command history&lt;br /&gt;
**A directory stack (pushd, popd)&lt;br /&gt;
**Command substitution&lt;br /&gt;
**Special variables, like $PPID&lt;br /&gt;
**Autocompletion&lt;br /&gt;
**In-process integer arithmetic: $((...))&lt;br /&gt;
**In-process regexes&lt;br /&gt;
**Aliases&lt;br /&gt;
**Functions&lt;br /&gt;
**Arrays&lt;br /&gt;
**Expansions: tilde, brace, variable&lt;br /&gt;
**Substring awesomeness&lt;br /&gt;
**Conditional expressions&lt;br /&gt;
**Security (restricted shell mode)&lt;br /&gt;
**Job Control&lt;br /&gt;
**Timing&lt;br /&gt;
**Prompt customization&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Using Bash for administrating=&lt;br /&gt;
==Useful commands==&lt;br /&gt;
===Command: find===&lt;br /&gt;
Search for files in the given directory, hierarchically starting at the parent directory and moving to sub-directories.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# find -name *.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: grep===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep user /etc/passwd &lt;br /&gt;
user:x:1000:1000:user,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Ignore word case and all other combination with ‘-i‘ option.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -i USER /etc/passwd &lt;br /&gt;
user:x:1000:1000:User,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Search recursively (-r) i.e. read all files under each directory for a string “127.0.0.1“.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -r &amp;quot;127.0.0.1&amp;quot; /etc/ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: man===&lt;br /&gt;
The ‘man‘ is the system’s manual pager. Man provides online documentation for all the possible options with a command and its usages. Almost all the command comes with their corresponding manual pages. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# man bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Manual page for man page itself, similarly ‘man cat‘ (Manual page for cat command) and ‘man ls‘ (Manual page for command ls).&lt;br /&gt;
&lt;br /&gt;
===Command: ps===&lt;br /&gt;
ps (Process) gives the status of running processes with a unique Id called PID.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
To list status of all the processes along with process id and PID, use option ‘-A‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: This command is very useful when you want to know which processes are running or may need PID sometimes, for process to be killed. You can use it with ‘grep‘ command to find customised output. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i ssh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Here ‘ps‘ is pipelined with ‘grep‘ command to find customised and relevant output of our need.&lt;br /&gt;
&lt;br /&gt;
===Command: kill===&lt;br /&gt;
You need a process’s pid (ps) to kill it.&lt;br /&gt;
Let suppose you want to kill program ‘apache2‘ that might not be responding. Run ‘ps -A‘ along with grep command.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i apache2&lt;br /&gt;
1285 ?        00:00:00 apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Find process ‘apache2‘, note its pid and kill it. For example, in that case ‘apache2‘ pid is ‘1285‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# kill 1285 (to kill the process apache2)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Every time you re-run a process or start a system, a new pid is generated for each process and you can know about the current running processes and its pid using command ‘ps‘.&lt;br /&gt;
Another way to kill the same process is.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# pkill apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Kill requires job id / process id for sending signals, where as in pkill, you have an option of using pattern, specifying process owner, etc.&lt;br /&gt;
&lt;br /&gt;
===Command: whereis===&lt;br /&gt;
The ‘whereis‘ command is used to locate the Binary, Sources and Manual Pages of the command. For example, to locate the Binary, Sources and Manual Pages of the command ‘ls‘ and ‘kill‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# whereis ls &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# whereis kill&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: This is useful to know where the binaries are installed for manual editing sometimes.&lt;br /&gt;
&lt;br /&gt;
===Command: service===&lt;br /&gt;
The ‘service‘ command controls the Starting, Stopping or Restarting of a ‘service‘. This command make it possible to start, restart or stop a service without restarting the system, for the changes to be taken into effect.&lt;br /&gt;
&lt;br /&gt;
Startting an apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# service apache2 start&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restarting a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# service apache2 restart&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stopping a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Stopping a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: All the process script lies in ‘/etc/init.d‘, and the path might needs to be included on certain system, i.e., in spite of running “service apache2 start” you would be asked to run “/etc/init.d/apache2 start”.&lt;br /&gt;
&lt;br /&gt;
===Command: alias===&lt;br /&gt;
alias is a built in shell command that lets you assign name for a long command or frequently used command.&lt;br /&gt;
For example.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
alias root=&#039;sudo -i&#039;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Command: df===&lt;br /&gt;
Report disk usages of file system. Useful for user as well as System Administrator to keep track of their disk usages. ‘df‘ works by examining directory entries, which generally are updated only when a file is closed.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# df&lt;br /&gt;
Filesystem     1K-blocks    Used Available Use% Mounted on&lt;br /&gt;
/dev/sda1       47929224 7811908  37675948  18% /&lt;br /&gt;
none                   4       0         4   0% /sys/fs/cgroup&lt;br /&gt;
udev             1005916       4   1005912   1% /dev&lt;br /&gt;
tmpfs             202824     816    202008   1% /run&lt;br /&gt;
none                5120       0      5120   0% /run/lock&lt;br /&gt;
none             1014120     628   1013492   1% /run/shm&lt;br /&gt;
none              102400      44    102356   1% /run/user&lt;br /&gt;
/dev/sda5         184307   79852     94727  46% /boot&lt;br /&gt;
/dev/sda7       95989516   61104  91045676   1% /data&lt;br /&gt;
/dev/sda8       91953192   57032  87218528   1% /personal&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Command: du===&lt;br /&gt;
Estimate file space usage. Output the summary of disk usages by ever file hierarchically, i.e., in recursive manner.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# du&lt;br /&gt;
308   ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/icons&lt;br /&gt;
344   ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop&lt;br /&gt;
4     ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/applet&lt;br /&gt;
548   ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/oblique-fonts&lt;br /&gt;
2048  ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/fonts&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: ‘df‘ only reports usage statistics on file systems, while ‘du‘, on the other hand, measures directory contents.&lt;br /&gt;
==Bash scripts==&lt;br /&gt;
===Cpu monitoring===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
while [ true ] ;do&lt;br /&gt;
used=`free -m |awk &#039;NR==3 {print $4}&#039;`&lt;br /&gt;
&lt;br /&gt;
if [ $used -lt 1000 ] &amp;amp;&amp;amp; [ $used -gt 800 ]; then&lt;br /&gt;
echo &amp;quot;Free memory is below 1000MB. Possible memory leak!!!&amp;quot; | /bin/mail -s &amp;quot;HIGH MEMORY ALERT!!!&amp;quot; user@itcollege.ee&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
fi&lt;br /&gt;
sleep 5&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
===Adding new users to a Linux system===&lt;br /&gt;
This script allows the root user or admin to add new users to the system in an easier way by just typing the user name and password (The password is entered in an encrypted manner).&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
# Script to add a user to Linux system&lt;br /&gt;
if [ $(id -u) -eq 0 ]; then&lt;br /&gt;
    read -p &amp;quot;Enter username : &amp;quot; username&lt;br /&gt;
    read -s -p &amp;quot;Enter password : &amp;quot; password&lt;br /&gt;
    egrep &amp;quot;^$username&amp;quot; /etc/passwd &amp;gt;/dev/null&lt;br /&gt;
    if [ $? -eq 0 ]; then&lt;br /&gt;
        echo &amp;quot;$username exists!&amp;quot;&lt;br /&gt;
        exit 1&lt;br /&gt;
    else&lt;br /&gt;
        pass=$(perl -e &#039;print crypt($ARGV[0], &amp;quot;password&amp;quot;)&#039; $password)&lt;br /&gt;
        useradd -m -p $pass $username&lt;br /&gt;
        [ $? -eq 0 ] &amp;amp;&amp;amp; echo &amp;quot;User has been added to system!&amp;quot; || echo &amp;quot;Failed to add a user!&amp;quot;&lt;br /&gt;
    fi&lt;br /&gt;
else&lt;br /&gt;
    echo &amp;quot;Only root may add a user to the system&amp;quot;&lt;br /&gt;
    exit 2&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
===Login Script===&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo su student2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if u run:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash --login&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if you login to a machine via ssh e.g:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@machine&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll be invoking ~/.profile Note that ~/.profile (or if not there, one of ~/.bash_profile or ~/.bash_login) normally contains relevant commands to run another script called ~/.bashrc (if said file exists):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if [ -f ~/.bashrc ]; then&lt;br /&gt;
    . ~/.bashrc&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Checking Server Utilization===&lt;br /&gt;
Checking the server utilization is one of the important task of an administrator, and a good administrator is one who knows how to automate his day to day task. Below is the script that will give many such information about your server&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
date;&lt;br /&gt;
echo &amp;quot;uptime:&amp;quot;&lt;br /&gt;
uptime&lt;br /&gt;
echo &amp;quot;Currently connected:&amp;quot;&lt;br /&gt;
w&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;Last logins:&amp;quot;&lt;br /&gt;
last -a |head -3&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;Disk and memory usage:&amp;quot;&lt;br /&gt;
df -h | xargs | awk &#039;{print &amp;quot;Free/total disk: &amp;quot; $11 &amp;quot; / &amp;quot; $9}&#039;&lt;br /&gt;
free -m | xargs | awk &#039;{print &amp;quot;Free/total memory: &amp;quot; $17 &amp;quot; / &amp;quot; $8 &amp;quot; MB&amp;quot;}&#039;&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
start_log=`head -1 /var/log/messages |cut -c 1-12`&lt;br /&gt;
oom=`grep -ci kill /var/log/messages`&lt;br /&gt;
echo -n &amp;quot;OOM errors since $start_log :&amp;quot; $oom&lt;br /&gt;
echo &amp;quot;&amp;quot;&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;Utilization and most expensive processes:&amp;quot;&lt;br /&gt;
top -b |head -3&lt;br /&gt;
echo&lt;br /&gt;
top -b |head -10 |tail -4&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;Open TCP ports:&amp;quot;&lt;br /&gt;
nmap -p- -T4 127.0.0.1&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;Current connections:&amp;quot;&lt;br /&gt;
ss -s&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;processes:&amp;quot;&lt;br /&gt;
ps auxf --width=200&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;vmstat:&amp;quot;&lt;br /&gt;
vmstat 1 5&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121304</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121304"/>
		<updated>2017-05-07T15:36:09Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* =Checking Server Utilization */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
It is a powerful shell, and features, among other things:&lt;br /&gt;
&lt;br /&gt;
**Command line editing&lt;br /&gt;
**Command history&lt;br /&gt;
**A directory stack (pushd, popd)&lt;br /&gt;
**Command substitution&lt;br /&gt;
**Special variables, like $PPID&lt;br /&gt;
**Autocompletion&lt;br /&gt;
**In-process integer arithmetic: $((...))&lt;br /&gt;
**In-process regexes&lt;br /&gt;
**Aliases&lt;br /&gt;
**Functions&lt;br /&gt;
**Arrays&lt;br /&gt;
**Expansions: tilde, brace, variable&lt;br /&gt;
**Substring awesomeness&lt;br /&gt;
**Conditional expressions&lt;br /&gt;
**Security (restricted shell mode)&lt;br /&gt;
**Job Control&lt;br /&gt;
**Timing&lt;br /&gt;
**Prompt customization&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Using Bash for administrating=&lt;br /&gt;
==Useful commands==&lt;br /&gt;
===Command: find===&lt;br /&gt;
Search for files in the given directory, hierarchically starting at the parent directory and moving to sub-directories.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# find -name *.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: grep===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep user /etc/passwd &lt;br /&gt;
user:x:1000:1000:user,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Ignore word case and all other combination with ‘-i‘ option.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -i USER /etc/passwd &lt;br /&gt;
user:x:1000:1000:User,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Search recursively (-r) i.e. read all files under each directory for a string “127.0.0.1“.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -r &amp;quot;127.0.0.1&amp;quot; /etc/ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: man===&lt;br /&gt;
The ‘man‘ is the system’s manual pager. Man provides online documentation for all the possible options with a command and its usages. Almost all the command comes with their corresponding manual pages. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# man bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Manual page for man page itself, similarly ‘man cat‘ (Manual page for cat command) and ‘man ls‘ (Manual page for command ls).&lt;br /&gt;
&lt;br /&gt;
===Command: ps===&lt;br /&gt;
ps (Process) gives the status of running processes with a unique Id called PID.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
To list status of all the processes along with process id and PID, use option ‘-A‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: This command is very useful when you want to know which processes are running or may need PID sometimes, for process to be killed. You can use it with ‘grep‘ command to find customised output. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i ssh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Here ‘ps‘ is pipelined with ‘grep‘ command to find customised and relevant output of our need.&lt;br /&gt;
&lt;br /&gt;
===Command: kill===&lt;br /&gt;
You need a process’s pid (ps) to kill it.&lt;br /&gt;
Let suppose you want to kill program ‘apache2‘ that might not be responding. Run ‘ps -A‘ along with grep command.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i apache2&lt;br /&gt;
1285 ?        00:00:00 apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Find process ‘apache2‘, note its pid and kill it. For example, in that case ‘apache2‘ pid is ‘1285‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# kill 1285 (to kill the process apache2)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Every time you re-run a process or start a system, a new pid is generated for each process and you can know about the current running processes and its pid using command ‘ps‘.&lt;br /&gt;
Another way to kill the same process is.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# pkill apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Kill requires job id / process id for sending signals, where as in pkill, you have an option of using pattern, specifying process owner, etc.&lt;br /&gt;
&lt;br /&gt;
===Command: whereis===&lt;br /&gt;
The ‘whereis‘ command is used to locate the Binary, Sources and Manual Pages of the command. For example, to locate the Binary, Sources and Manual Pages of the command ‘ls‘ and ‘kill‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# whereis ls &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# whereis kill&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: This is useful to know where the binaries are installed for manual editing sometimes.&lt;br /&gt;
&lt;br /&gt;
===Command: service===&lt;br /&gt;
The ‘service‘ command controls the Starting, Stopping or Restarting of a ‘service‘. This command make it possible to start, restart or stop a service without restarting the system, for the changes to be taken into effect.&lt;br /&gt;
&lt;br /&gt;
Startting an apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# service apache2 start&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restarting a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# service apache2 restart&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stopping a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Stopping a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: All the process script lies in ‘/etc/init.d‘, and the path might needs to be included on certain system, i.e., in spite of running “service apache2 start” you would be asked to run “/etc/init.d/apache2 start”.&lt;br /&gt;
&lt;br /&gt;
===Command: alias===&lt;br /&gt;
alias is a built in shell command that lets you assign name for a long command or frequently used command.&lt;br /&gt;
For example.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
alias root=&#039;sudo -i&#039;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Command: df===&lt;br /&gt;
Report disk usages of file system. Useful for user as well as System Administrator to keep track of their disk usages. ‘df‘ works by examining directory entries, which generally are updated only when a file is closed.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# df&lt;br /&gt;
Filesystem     1K-blocks    Used Available Use% Mounted on&lt;br /&gt;
/dev/sda1       47929224 7811908  37675948  18% /&lt;br /&gt;
none                   4       0         4   0% /sys/fs/cgroup&lt;br /&gt;
udev             1005916       4   1005912   1% /dev&lt;br /&gt;
tmpfs             202824     816    202008   1% /run&lt;br /&gt;
none                5120       0      5120   0% /run/lock&lt;br /&gt;
none             1014120     628   1013492   1% /run/shm&lt;br /&gt;
none              102400      44    102356   1% /run/user&lt;br /&gt;
/dev/sda5         184307   79852     94727  46% /boot&lt;br /&gt;
/dev/sda7       95989516   61104  91045676   1% /data&lt;br /&gt;
/dev/sda8       91953192   57032  87218528   1% /personal&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Command: du===&lt;br /&gt;
Estimate file space usage. Output the summary of disk usages by ever file hierarchically, i.e., in recursive manner.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# du&lt;br /&gt;
308   ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/icons&lt;br /&gt;
344   ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop&lt;br /&gt;
4     ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/applet&lt;br /&gt;
548   ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/oblique-fonts&lt;br /&gt;
2048  ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/fonts&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: ‘df‘ only reports usage statistics on file systems, while ‘du‘, on the other hand, measures directory contents.&lt;br /&gt;
==Bash scripts==&lt;br /&gt;
===Cpu monitoring===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
while [ true ] ;do&lt;br /&gt;
used=`free -m |awk &#039;NR==3 {print $4}&#039;`&lt;br /&gt;
&lt;br /&gt;
if [ $used -lt 1000 ] &amp;amp;&amp;amp; [ $used -gt 800 ]; then&lt;br /&gt;
echo &amp;quot;Free memory is below 1000MB. Possible memory leak!!!&amp;quot; | /bin/mail -s &amp;quot;HIGH MEMORY ALERT!!!&amp;quot; user@itcollege.ee&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
fi&lt;br /&gt;
sleep 5&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
===Adding new users to a Linux system===&lt;br /&gt;
This script allows the root user or admin to add new users to the system in an easier way by just typing the user name and password (The password is entered in an encrypted manner).&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
# Script to add a user to Linux system&lt;br /&gt;
if [ $(id -u) -eq 0 ]; then&lt;br /&gt;
    read -p &amp;quot;Enter username : &amp;quot; username&lt;br /&gt;
    read -s -p &amp;quot;Enter password : &amp;quot; password&lt;br /&gt;
    egrep &amp;quot;^$username&amp;quot; /etc/passwd &amp;gt;/dev/null&lt;br /&gt;
    if [ $? -eq 0 ]; then&lt;br /&gt;
        echo &amp;quot;$username exists!&amp;quot;&lt;br /&gt;
        exit 1&lt;br /&gt;
    else&lt;br /&gt;
        pass=$(perl -e &#039;print crypt($ARGV[0], &amp;quot;password&amp;quot;)&#039; $password)&lt;br /&gt;
        useradd -m -p $pass $username&lt;br /&gt;
        [ $? -eq 0 ] &amp;amp;&amp;amp; echo &amp;quot;User has been added to system!&amp;quot; || echo &amp;quot;Failed to add a user!&amp;quot;&lt;br /&gt;
    fi&lt;br /&gt;
else&lt;br /&gt;
    echo &amp;quot;Only root may add a user to the system&amp;quot;&lt;br /&gt;
    exit 2&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
===Login Script===&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo su student2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if u run:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash --login&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if you login to a machine via ssh e.g:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@machine&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll be invoking ~/.profile Note that ~/.profile (or if not there, one of ~/.bash_profile or ~/.bash_login) normally contains relevant commands to run another script called ~/.bashrc (if said file exists):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if [ -f ~/.bashrc ]; then&lt;br /&gt;
    . ~/.bashrc&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Checking Server Utilization===&lt;br /&gt;
Checking the server utilization is one of the important task of an administrator, and a good administrator is one who knows how to automate his day to day task. Below is the script that will give many such information about your server&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
date;&lt;br /&gt;
echo &amp;quot;uptime:&amp;quot;&lt;br /&gt;
uptime&lt;br /&gt;
echo &amp;quot;Currently connected:&amp;quot;&lt;br /&gt;
w&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;Last logins:&amp;quot;&lt;br /&gt;
last -a |head -3&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;Disk and memory usage:&amp;quot;&lt;br /&gt;
df -h | xargs | awk &#039;{print &amp;quot;Free/total disk: &amp;quot; $11 &amp;quot; / &amp;quot; $9}&#039;&lt;br /&gt;
free -m | xargs | awk &#039;{print &amp;quot;Free/total memory: &amp;quot; $17 &amp;quot; / &amp;quot; $8 &amp;quot; MB&amp;quot;}&#039;&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
start_log=`head -1 /var/log/messages |cut -c 1-12`&lt;br /&gt;
oom=`grep -ci kill /var/log/messages`&lt;br /&gt;
echo -n &amp;quot;OOM errors since $start_log :&amp;quot; $oom&lt;br /&gt;
echo &amp;quot;&amp;quot;&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;Utilization and most expensive processes:&amp;quot;&lt;br /&gt;
top -b |head -3&lt;br /&gt;
echo&lt;br /&gt;
top -b |head -10 |tail -4&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;Open TCP ports:&amp;quot;&lt;br /&gt;
nmap -p- -T4 127.0.0.1&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;Current connections:&amp;quot;&lt;br /&gt;
ss -s&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;processes:&amp;quot;&lt;br /&gt;
ps auxf --width=200&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;vmstat:&amp;quot;&lt;br /&gt;
vmstat 1 5&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121303</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121303"/>
		<updated>2017-05-07T15:35:45Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Bash scripts */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
It is a powerful shell, and features, among other things:&lt;br /&gt;
&lt;br /&gt;
**Command line editing&lt;br /&gt;
**Command history&lt;br /&gt;
**A directory stack (pushd, popd)&lt;br /&gt;
**Command substitution&lt;br /&gt;
**Special variables, like $PPID&lt;br /&gt;
**Autocompletion&lt;br /&gt;
**In-process integer arithmetic: $((...))&lt;br /&gt;
**In-process regexes&lt;br /&gt;
**Aliases&lt;br /&gt;
**Functions&lt;br /&gt;
**Arrays&lt;br /&gt;
**Expansions: tilde, brace, variable&lt;br /&gt;
**Substring awesomeness&lt;br /&gt;
**Conditional expressions&lt;br /&gt;
**Security (restricted shell mode)&lt;br /&gt;
**Job Control&lt;br /&gt;
**Timing&lt;br /&gt;
**Prompt customization&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Using Bash for administrating=&lt;br /&gt;
==Useful commands==&lt;br /&gt;
===Command: find===&lt;br /&gt;
Search for files in the given directory, hierarchically starting at the parent directory and moving to sub-directories.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# find -name *.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: grep===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep user /etc/passwd &lt;br /&gt;
user:x:1000:1000:user,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Ignore word case and all other combination with ‘-i‘ option.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -i USER /etc/passwd &lt;br /&gt;
user:x:1000:1000:User,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Search recursively (-r) i.e. read all files under each directory for a string “127.0.0.1“.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -r &amp;quot;127.0.0.1&amp;quot; /etc/ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: man===&lt;br /&gt;
The ‘man‘ is the system’s manual pager. Man provides online documentation for all the possible options with a command and its usages. Almost all the command comes with their corresponding manual pages. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# man bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Manual page for man page itself, similarly ‘man cat‘ (Manual page for cat command) and ‘man ls‘ (Manual page for command ls).&lt;br /&gt;
&lt;br /&gt;
===Command: ps===&lt;br /&gt;
ps (Process) gives the status of running processes with a unique Id called PID.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
To list status of all the processes along with process id and PID, use option ‘-A‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: This command is very useful when you want to know which processes are running or may need PID sometimes, for process to be killed. You can use it with ‘grep‘ command to find customised output. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i ssh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Here ‘ps‘ is pipelined with ‘grep‘ command to find customised and relevant output of our need.&lt;br /&gt;
&lt;br /&gt;
===Command: kill===&lt;br /&gt;
You need a process’s pid (ps) to kill it.&lt;br /&gt;
Let suppose you want to kill program ‘apache2‘ that might not be responding. Run ‘ps -A‘ along with grep command.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i apache2&lt;br /&gt;
1285 ?        00:00:00 apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Find process ‘apache2‘, note its pid and kill it. For example, in that case ‘apache2‘ pid is ‘1285‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# kill 1285 (to kill the process apache2)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Every time you re-run a process or start a system, a new pid is generated for each process and you can know about the current running processes and its pid using command ‘ps‘.&lt;br /&gt;
Another way to kill the same process is.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# pkill apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Kill requires job id / process id for sending signals, where as in pkill, you have an option of using pattern, specifying process owner, etc.&lt;br /&gt;
&lt;br /&gt;
===Command: whereis===&lt;br /&gt;
The ‘whereis‘ command is used to locate the Binary, Sources and Manual Pages of the command. For example, to locate the Binary, Sources and Manual Pages of the command ‘ls‘ and ‘kill‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# whereis ls &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# whereis kill&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: This is useful to know where the binaries are installed for manual editing sometimes.&lt;br /&gt;
&lt;br /&gt;
===Command: service===&lt;br /&gt;
The ‘service‘ command controls the Starting, Stopping or Restarting of a ‘service‘. This command make it possible to start, restart or stop a service without restarting the system, for the changes to be taken into effect.&lt;br /&gt;
&lt;br /&gt;
Startting an apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# service apache2 start&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restarting a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# service apache2 restart&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stopping a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Stopping a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: All the process script lies in ‘/etc/init.d‘, and the path might needs to be included on certain system, i.e., in spite of running “service apache2 start” you would be asked to run “/etc/init.d/apache2 start”.&lt;br /&gt;
&lt;br /&gt;
===Command: alias===&lt;br /&gt;
alias is a built in shell command that lets you assign name for a long command or frequently used command.&lt;br /&gt;
For example.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
alias root=&#039;sudo -i&#039;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Command: df===&lt;br /&gt;
Report disk usages of file system. Useful for user as well as System Administrator to keep track of their disk usages. ‘df‘ works by examining directory entries, which generally are updated only when a file is closed.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# df&lt;br /&gt;
Filesystem     1K-blocks    Used Available Use% Mounted on&lt;br /&gt;
/dev/sda1       47929224 7811908  37675948  18% /&lt;br /&gt;
none                   4       0         4   0% /sys/fs/cgroup&lt;br /&gt;
udev             1005916       4   1005912   1% /dev&lt;br /&gt;
tmpfs             202824     816    202008   1% /run&lt;br /&gt;
none                5120       0      5120   0% /run/lock&lt;br /&gt;
none             1014120     628   1013492   1% /run/shm&lt;br /&gt;
none              102400      44    102356   1% /run/user&lt;br /&gt;
/dev/sda5         184307   79852     94727  46% /boot&lt;br /&gt;
/dev/sda7       95989516   61104  91045676   1% /data&lt;br /&gt;
/dev/sda8       91953192   57032  87218528   1% /personal&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Command: du===&lt;br /&gt;
Estimate file space usage. Output the summary of disk usages by ever file hierarchically, i.e., in recursive manner.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# du&lt;br /&gt;
308   ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/icons&lt;br /&gt;
344   ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop&lt;br /&gt;
4     ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/applet&lt;br /&gt;
548   ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/oblique-fonts&lt;br /&gt;
2048  ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/fonts&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: ‘df‘ only reports usage statistics on file systems, while ‘du‘, on the other hand, measures directory contents.&lt;br /&gt;
==Bash scripts==&lt;br /&gt;
===Cpu monitoring===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
while [ true ] ;do&lt;br /&gt;
used=`free -m |awk &#039;NR==3 {print $4}&#039;`&lt;br /&gt;
&lt;br /&gt;
if [ $used -lt 1000 ] &amp;amp;&amp;amp; [ $used -gt 800 ]; then&lt;br /&gt;
echo &amp;quot;Free memory is below 1000MB. Possible memory leak!!!&amp;quot; | /bin/mail -s &amp;quot;HIGH MEMORY ALERT!!!&amp;quot; user@itcollege.ee&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
fi&lt;br /&gt;
sleep 5&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
===Adding new users to a Linux system===&lt;br /&gt;
This script allows the root user or admin to add new users to the system in an easier way by just typing the user name and password (The password is entered in an encrypted manner).&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
# Script to add a user to Linux system&lt;br /&gt;
if [ $(id -u) -eq 0 ]; then&lt;br /&gt;
    read -p &amp;quot;Enter username : &amp;quot; username&lt;br /&gt;
    read -s -p &amp;quot;Enter password : &amp;quot; password&lt;br /&gt;
    egrep &amp;quot;^$username&amp;quot; /etc/passwd &amp;gt;/dev/null&lt;br /&gt;
    if [ $? -eq 0 ]; then&lt;br /&gt;
        echo &amp;quot;$username exists!&amp;quot;&lt;br /&gt;
        exit 1&lt;br /&gt;
    else&lt;br /&gt;
        pass=$(perl -e &#039;print crypt($ARGV[0], &amp;quot;password&amp;quot;)&#039; $password)&lt;br /&gt;
        useradd -m -p $pass $username&lt;br /&gt;
        [ $? -eq 0 ] &amp;amp;&amp;amp; echo &amp;quot;User has been added to system!&amp;quot; || echo &amp;quot;Failed to add a user!&amp;quot;&lt;br /&gt;
    fi&lt;br /&gt;
else&lt;br /&gt;
    echo &amp;quot;Only root may add a user to the system&amp;quot;&lt;br /&gt;
    exit 2&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
===Login Script===&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo su student2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if u run:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash --login&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if you login to a machine via ssh e.g:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@machine&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll be invoking ~/.profile Note that ~/.profile (or if not there, one of ~/.bash_profile or ~/.bash_login) normally contains relevant commands to run another script called ~/.bashrc (if said file exists):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if [ -f ~/.bashrc ]; then&lt;br /&gt;
    . ~/.bashrc&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Checking Server Utilization==&lt;br /&gt;
Checking the server utilization is one of the important task of an administrator, and a good administrator is one who knows how to automate his day to day task. Below is the script that will give many such information about your server&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
date;&lt;br /&gt;
echo &amp;quot;uptime:&amp;quot;&lt;br /&gt;
uptime&lt;br /&gt;
echo &amp;quot;Currently connected:&amp;quot;&lt;br /&gt;
w&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;Last logins:&amp;quot;&lt;br /&gt;
last -a |head -3&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;Disk and memory usage:&amp;quot;&lt;br /&gt;
df -h | xargs | awk &#039;{print &amp;quot;Free/total disk: &amp;quot; $11 &amp;quot; / &amp;quot; $9}&#039;&lt;br /&gt;
free -m | xargs | awk &#039;{print &amp;quot;Free/total memory: &amp;quot; $17 &amp;quot; / &amp;quot; $8 &amp;quot; MB&amp;quot;}&#039;&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
start_log=`head -1 /var/log/messages |cut -c 1-12`&lt;br /&gt;
oom=`grep -ci kill /var/log/messages`&lt;br /&gt;
echo -n &amp;quot;OOM errors since $start_log :&amp;quot; $oom&lt;br /&gt;
echo &amp;quot;&amp;quot;&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;Utilization and most expensive processes:&amp;quot;&lt;br /&gt;
top -b |head -3&lt;br /&gt;
echo&lt;br /&gt;
top -b |head -10 |tail -4&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;Open TCP ports:&amp;quot;&lt;br /&gt;
nmap -p- -T4 127.0.0.1&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;Current connections:&amp;quot;&lt;br /&gt;
ss -s&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;processes:&amp;quot;&lt;br /&gt;
ps auxf --width=200&lt;br /&gt;
echo &amp;quot;--------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;vmstat:&amp;quot;&lt;br /&gt;
vmstat 1 5&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121302</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121302"/>
		<updated>2017-05-07T15:29:11Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Bash scripts */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
It is a powerful shell, and features, among other things:&lt;br /&gt;
&lt;br /&gt;
**Command line editing&lt;br /&gt;
**Command history&lt;br /&gt;
**A directory stack (pushd, popd)&lt;br /&gt;
**Command substitution&lt;br /&gt;
**Special variables, like $PPID&lt;br /&gt;
**Autocompletion&lt;br /&gt;
**In-process integer arithmetic: $((...))&lt;br /&gt;
**In-process regexes&lt;br /&gt;
**Aliases&lt;br /&gt;
**Functions&lt;br /&gt;
**Arrays&lt;br /&gt;
**Expansions: tilde, brace, variable&lt;br /&gt;
**Substring awesomeness&lt;br /&gt;
**Conditional expressions&lt;br /&gt;
**Security (restricted shell mode)&lt;br /&gt;
**Job Control&lt;br /&gt;
**Timing&lt;br /&gt;
**Prompt customization&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Using Bash for administrating=&lt;br /&gt;
==Useful commands==&lt;br /&gt;
===Command: find===&lt;br /&gt;
Search for files in the given directory, hierarchically starting at the parent directory and moving to sub-directories.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# find -name *.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: grep===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep user /etc/passwd &lt;br /&gt;
user:x:1000:1000:user,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Ignore word case and all other combination with ‘-i‘ option.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -i USER /etc/passwd &lt;br /&gt;
user:x:1000:1000:User,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Search recursively (-r) i.e. read all files under each directory for a string “127.0.0.1“.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -r &amp;quot;127.0.0.1&amp;quot; /etc/ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: man===&lt;br /&gt;
The ‘man‘ is the system’s manual pager. Man provides online documentation for all the possible options with a command and its usages. Almost all the command comes with their corresponding manual pages. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# man bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Manual page for man page itself, similarly ‘man cat‘ (Manual page for cat command) and ‘man ls‘ (Manual page for command ls).&lt;br /&gt;
&lt;br /&gt;
===Command: ps===&lt;br /&gt;
ps (Process) gives the status of running processes with a unique Id called PID.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
To list status of all the processes along with process id and PID, use option ‘-A‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: This command is very useful when you want to know which processes are running or may need PID sometimes, for process to be killed. You can use it with ‘grep‘ command to find customised output. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i ssh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Here ‘ps‘ is pipelined with ‘grep‘ command to find customised and relevant output of our need.&lt;br /&gt;
&lt;br /&gt;
===Command: kill===&lt;br /&gt;
You need a process’s pid (ps) to kill it.&lt;br /&gt;
Let suppose you want to kill program ‘apache2‘ that might not be responding. Run ‘ps -A‘ along with grep command.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i apache2&lt;br /&gt;
1285 ?        00:00:00 apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Find process ‘apache2‘, note its pid and kill it. For example, in that case ‘apache2‘ pid is ‘1285‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# kill 1285 (to kill the process apache2)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Every time you re-run a process or start a system, a new pid is generated for each process and you can know about the current running processes and its pid using command ‘ps‘.&lt;br /&gt;
Another way to kill the same process is.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# pkill apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Kill requires job id / process id for sending signals, where as in pkill, you have an option of using pattern, specifying process owner, etc.&lt;br /&gt;
&lt;br /&gt;
===Command: whereis===&lt;br /&gt;
The ‘whereis‘ command is used to locate the Binary, Sources and Manual Pages of the command. For example, to locate the Binary, Sources and Manual Pages of the command ‘ls‘ and ‘kill‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# whereis ls &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# whereis kill&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: This is useful to know where the binaries are installed for manual editing sometimes.&lt;br /&gt;
&lt;br /&gt;
===Command: service===&lt;br /&gt;
The ‘service‘ command controls the Starting, Stopping or Restarting of a ‘service‘. This command make it possible to start, restart or stop a service without restarting the system, for the changes to be taken into effect.&lt;br /&gt;
&lt;br /&gt;
Startting an apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# service apache2 start&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restarting a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# service apache2 restart&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stopping a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Stopping a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: All the process script lies in ‘/etc/init.d‘, and the path might needs to be included on certain system, i.e., in spite of running “service apache2 start” you would be asked to run “/etc/init.d/apache2 start”.&lt;br /&gt;
&lt;br /&gt;
===Command: alias===&lt;br /&gt;
alias is a built in shell command that lets you assign name for a long command or frequently used command.&lt;br /&gt;
For example.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
alias root=&#039;sudo -i&#039;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Command: df===&lt;br /&gt;
Report disk usages of file system. Useful for user as well as System Administrator to keep track of their disk usages. ‘df‘ works by examining directory entries, which generally are updated only when a file is closed.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# df&lt;br /&gt;
Filesystem     1K-blocks    Used Available Use% Mounted on&lt;br /&gt;
/dev/sda1       47929224 7811908  37675948  18% /&lt;br /&gt;
none                   4       0         4   0% /sys/fs/cgroup&lt;br /&gt;
udev             1005916       4   1005912   1% /dev&lt;br /&gt;
tmpfs             202824     816    202008   1% /run&lt;br /&gt;
none                5120       0      5120   0% /run/lock&lt;br /&gt;
none             1014120     628   1013492   1% /run/shm&lt;br /&gt;
none              102400      44    102356   1% /run/user&lt;br /&gt;
/dev/sda5         184307   79852     94727  46% /boot&lt;br /&gt;
/dev/sda7       95989516   61104  91045676   1% /data&lt;br /&gt;
/dev/sda8       91953192   57032  87218528   1% /personal&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Command: du===&lt;br /&gt;
Estimate file space usage. Output the summary of disk usages by ever file hierarchically, i.e., in recursive manner.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# du&lt;br /&gt;
308   ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/icons&lt;br /&gt;
344   ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop&lt;br /&gt;
4     ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/applet&lt;br /&gt;
548   ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/oblique-fonts&lt;br /&gt;
2048  ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/fonts&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: ‘df‘ only reports usage statistics on file systems, while ‘du‘, on the other hand, measures directory contents.&lt;br /&gt;
==Bash scripts==&lt;br /&gt;
===Cpu monitoring===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
while [ true ] ;do&lt;br /&gt;
used=`free -m |awk &#039;NR==3 {print $4}&#039;`&lt;br /&gt;
&lt;br /&gt;
if [ $used -lt 1000 ] &amp;amp;&amp;amp; [ $used -gt 800 ]; then&lt;br /&gt;
echo &amp;quot;Free memory is below 1000MB. Possible memory leak!!!&amp;quot; | /bin/mail -s &amp;quot;HIGH MEMORY ALERT!!!&amp;quot; user@itcollege.ee&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
fi&lt;br /&gt;
sleep 5&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
===Adding new users to a Linux system===&lt;br /&gt;
This script allows the root user or admin to add new users to the system in an easier way by just typing the user name and password (The password is entered in an encrypted manner).&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
# Script to add a user to Linux system&lt;br /&gt;
if [ $(id -u) -eq 0 ]; then&lt;br /&gt;
    read -p &amp;quot;Enter username : &amp;quot; username&lt;br /&gt;
    read -s -p &amp;quot;Enter password : &amp;quot; password&lt;br /&gt;
    egrep &amp;quot;^$username&amp;quot; /etc/passwd &amp;gt;/dev/null&lt;br /&gt;
    if [ $? -eq 0 ]; then&lt;br /&gt;
        echo &amp;quot;$username exists!&amp;quot;&lt;br /&gt;
        exit 1&lt;br /&gt;
    else&lt;br /&gt;
        pass=$(perl -e &#039;print crypt($ARGV[0], &amp;quot;password&amp;quot;)&#039; $password)&lt;br /&gt;
        useradd -m -p $pass $username&lt;br /&gt;
        [ $? -eq 0 ] &amp;amp;&amp;amp; echo &amp;quot;User has been added to system!&amp;quot; || echo &amp;quot;Failed to add a user!&amp;quot;&lt;br /&gt;
    fi&lt;br /&gt;
else&lt;br /&gt;
    echo &amp;quot;Only root may add a user to the system&amp;quot;&lt;br /&gt;
    exit 2&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
===Login Script===&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo su student2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if u run:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash --login&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if you login to a machine via ssh e.g:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@machine&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll be invoking ~/.profile Note that ~/.profile (or if not there, one of ~/.bash_profile or ~/.bash_login) normally contains relevant commands to run another script called ~/.bashrc (if said file exists):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if [ -f ~/.bashrc ]; then&lt;br /&gt;
    . ~/.bashrc&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121301</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121301"/>
		<updated>2017-05-07T15:27:04Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Bash scripts */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
It is a powerful shell, and features, among other things:&lt;br /&gt;
&lt;br /&gt;
**Command line editing&lt;br /&gt;
**Command history&lt;br /&gt;
**A directory stack (pushd, popd)&lt;br /&gt;
**Command substitution&lt;br /&gt;
**Special variables, like $PPID&lt;br /&gt;
**Autocompletion&lt;br /&gt;
**In-process integer arithmetic: $((...))&lt;br /&gt;
**In-process regexes&lt;br /&gt;
**Aliases&lt;br /&gt;
**Functions&lt;br /&gt;
**Arrays&lt;br /&gt;
**Expansions: tilde, brace, variable&lt;br /&gt;
**Substring awesomeness&lt;br /&gt;
**Conditional expressions&lt;br /&gt;
**Security (restricted shell mode)&lt;br /&gt;
**Job Control&lt;br /&gt;
**Timing&lt;br /&gt;
**Prompt customization&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Using Bash for administrating=&lt;br /&gt;
==Useful commands==&lt;br /&gt;
===Command: find===&lt;br /&gt;
Search for files in the given directory, hierarchically starting at the parent directory and moving to sub-directories.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# find -name *.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: grep===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep user /etc/passwd &lt;br /&gt;
user:x:1000:1000:user,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Ignore word case and all other combination with ‘-i‘ option.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -i USER /etc/passwd &lt;br /&gt;
user:x:1000:1000:User,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Search recursively (-r) i.e. read all files under each directory for a string “127.0.0.1“.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -r &amp;quot;127.0.0.1&amp;quot; /etc/ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: man===&lt;br /&gt;
The ‘man‘ is the system’s manual pager. Man provides online documentation for all the possible options with a command and its usages. Almost all the command comes with their corresponding manual pages. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# man bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Manual page for man page itself, similarly ‘man cat‘ (Manual page for cat command) and ‘man ls‘ (Manual page for command ls).&lt;br /&gt;
&lt;br /&gt;
===Command: ps===&lt;br /&gt;
ps (Process) gives the status of running processes with a unique Id called PID.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
To list status of all the processes along with process id and PID, use option ‘-A‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: This command is very useful when you want to know which processes are running or may need PID sometimes, for process to be killed. You can use it with ‘grep‘ command to find customised output. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i ssh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Here ‘ps‘ is pipelined with ‘grep‘ command to find customised and relevant output of our need.&lt;br /&gt;
&lt;br /&gt;
===Command: kill===&lt;br /&gt;
You need a process’s pid (ps) to kill it.&lt;br /&gt;
Let suppose you want to kill program ‘apache2‘ that might not be responding. Run ‘ps -A‘ along with grep command.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i apache2&lt;br /&gt;
1285 ?        00:00:00 apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Find process ‘apache2‘, note its pid and kill it. For example, in that case ‘apache2‘ pid is ‘1285‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# kill 1285 (to kill the process apache2)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Every time you re-run a process or start a system, a new pid is generated for each process and you can know about the current running processes and its pid using command ‘ps‘.&lt;br /&gt;
Another way to kill the same process is.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# pkill apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Kill requires job id / process id for sending signals, where as in pkill, you have an option of using pattern, specifying process owner, etc.&lt;br /&gt;
&lt;br /&gt;
===Command: whereis===&lt;br /&gt;
The ‘whereis‘ command is used to locate the Binary, Sources and Manual Pages of the command. For example, to locate the Binary, Sources and Manual Pages of the command ‘ls‘ and ‘kill‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# whereis ls &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# whereis kill&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: This is useful to know where the binaries are installed for manual editing sometimes.&lt;br /&gt;
&lt;br /&gt;
===Command: service===&lt;br /&gt;
The ‘service‘ command controls the Starting, Stopping or Restarting of a ‘service‘. This command make it possible to start, restart or stop a service without restarting the system, for the changes to be taken into effect.&lt;br /&gt;
&lt;br /&gt;
Startting an apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# service apache2 start&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restarting a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# service apache2 restart&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stopping a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Stopping a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: All the process script lies in ‘/etc/init.d‘, and the path might needs to be included on certain system, i.e., in spite of running “service apache2 start” you would be asked to run “/etc/init.d/apache2 start”.&lt;br /&gt;
&lt;br /&gt;
===Command: alias===&lt;br /&gt;
alias is a built in shell command that lets you assign name for a long command or frequently used command.&lt;br /&gt;
For example.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
alias root=&#039;sudo -i&#039;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Command: df===&lt;br /&gt;
Report disk usages of file system. Useful for user as well as System Administrator to keep track of their disk usages. ‘df‘ works by examining directory entries, which generally are updated only when a file is closed.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# df&lt;br /&gt;
Filesystem     1K-blocks    Used Available Use% Mounted on&lt;br /&gt;
/dev/sda1       47929224 7811908  37675948  18% /&lt;br /&gt;
none                   4       0         4   0% /sys/fs/cgroup&lt;br /&gt;
udev             1005916       4   1005912   1% /dev&lt;br /&gt;
tmpfs             202824     816    202008   1% /run&lt;br /&gt;
none                5120       0      5120   0% /run/lock&lt;br /&gt;
none             1014120     628   1013492   1% /run/shm&lt;br /&gt;
none              102400      44    102356   1% /run/user&lt;br /&gt;
/dev/sda5         184307   79852     94727  46% /boot&lt;br /&gt;
/dev/sda7       95989516   61104  91045676   1% /data&lt;br /&gt;
/dev/sda8       91953192   57032  87218528   1% /personal&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Command: du===&lt;br /&gt;
Estimate file space usage. Output the summary of disk usages by ever file hierarchically, i.e., in recursive manner.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# du&lt;br /&gt;
308   ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/icons&lt;br /&gt;
344   ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop&lt;br /&gt;
4     ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/applet&lt;br /&gt;
548   ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/oblique-fonts&lt;br /&gt;
2048  ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/fonts&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: ‘df‘ only reports usage statistics on file systems, while ‘du‘, on the other hand, measures directory contents.&lt;br /&gt;
==Bash scripts==&lt;br /&gt;
===Adding new users to a Linux system===&lt;br /&gt;
This script allows the root user or admin to add new users to the system in an easier way by just typing the user name and password (The password is entered in an encrypted manner).&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
# Script to add a user to Linux system&lt;br /&gt;
if [ $(id -u) -eq 0 ]; then&lt;br /&gt;
    read -p &amp;quot;Enter username : &amp;quot; username&lt;br /&gt;
    read -s -p &amp;quot;Enter password : &amp;quot; password&lt;br /&gt;
    egrep &amp;quot;^$username&amp;quot; /etc/passwd &amp;gt;/dev/null&lt;br /&gt;
    if [ $? -eq 0 ]; then&lt;br /&gt;
        echo &amp;quot;$username exists!&amp;quot;&lt;br /&gt;
        exit 1&lt;br /&gt;
    else&lt;br /&gt;
        pass=$(perl -e &#039;print crypt($ARGV[0], &amp;quot;password&amp;quot;)&#039; $password)&lt;br /&gt;
        useradd -m -p $pass $username&lt;br /&gt;
        [ $? -eq 0 ] &amp;amp;&amp;amp; echo &amp;quot;User has been added to system!&amp;quot; || echo &amp;quot;Failed to add a user!&amp;quot;&lt;br /&gt;
    fi&lt;br /&gt;
else&lt;br /&gt;
    echo &amp;quot;Only root may add a user to the system&amp;quot;&lt;br /&gt;
    exit 2&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
===Login Script===&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo su student2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if u run:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash --login&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if you login to a machine via ssh e.g:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@machine&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll be invoking ~/.profile Note that ~/.profile (or if not there, one of ~/.bash_profile or ~/.bash_login) normally contains relevant commands to run another script called ~/.bashrc (if said file exists):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if [ -f ~/.bashrc ]; then&lt;br /&gt;
    . ~/.bashrc&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121300</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121300"/>
		<updated>2017-05-07T15:24:40Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Bash scripts */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
It is a powerful shell, and features, among other things:&lt;br /&gt;
&lt;br /&gt;
**Command line editing&lt;br /&gt;
**Command history&lt;br /&gt;
**A directory stack (pushd, popd)&lt;br /&gt;
**Command substitution&lt;br /&gt;
**Special variables, like $PPID&lt;br /&gt;
**Autocompletion&lt;br /&gt;
**In-process integer arithmetic: $((...))&lt;br /&gt;
**In-process regexes&lt;br /&gt;
**Aliases&lt;br /&gt;
**Functions&lt;br /&gt;
**Arrays&lt;br /&gt;
**Expansions: tilde, brace, variable&lt;br /&gt;
**Substring awesomeness&lt;br /&gt;
**Conditional expressions&lt;br /&gt;
**Security (restricted shell mode)&lt;br /&gt;
**Job Control&lt;br /&gt;
**Timing&lt;br /&gt;
**Prompt customization&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Using Bash for administrating=&lt;br /&gt;
==Useful commands==&lt;br /&gt;
===Command: find===&lt;br /&gt;
Search for files in the given directory, hierarchically starting at the parent directory and moving to sub-directories.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# find -name *.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: grep===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep user /etc/passwd &lt;br /&gt;
user:x:1000:1000:user,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Ignore word case and all other combination with ‘-i‘ option.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -i USER /etc/passwd &lt;br /&gt;
user:x:1000:1000:User,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Search recursively (-r) i.e. read all files under each directory for a string “127.0.0.1“.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -r &amp;quot;127.0.0.1&amp;quot; /etc/ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: man===&lt;br /&gt;
The ‘man‘ is the system’s manual pager. Man provides online documentation for all the possible options with a command and its usages. Almost all the command comes with their corresponding manual pages. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# man bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Manual page for man page itself, similarly ‘man cat‘ (Manual page for cat command) and ‘man ls‘ (Manual page for command ls).&lt;br /&gt;
&lt;br /&gt;
===Command: ps===&lt;br /&gt;
ps (Process) gives the status of running processes with a unique Id called PID.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
To list status of all the processes along with process id and PID, use option ‘-A‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: This command is very useful when you want to know which processes are running or may need PID sometimes, for process to be killed. You can use it with ‘grep‘ command to find customised output. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i ssh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Here ‘ps‘ is pipelined with ‘grep‘ command to find customised and relevant output of our need.&lt;br /&gt;
&lt;br /&gt;
===Command: kill===&lt;br /&gt;
You need a process’s pid (ps) to kill it.&lt;br /&gt;
Let suppose you want to kill program ‘apache2‘ that might not be responding. Run ‘ps -A‘ along with grep command.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i apache2&lt;br /&gt;
1285 ?        00:00:00 apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Find process ‘apache2‘, note its pid and kill it. For example, in that case ‘apache2‘ pid is ‘1285‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# kill 1285 (to kill the process apache2)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Every time you re-run a process or start a system, a new pid is generated for each process and you can know about the current running processes and its pid using command ‘ps‘.&lt;br /&gt;
Another way to kill the same process is.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# pkill apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Kill requires job id / process id for sending signals, where as in pkill, you have an option of using pattern, specifying process owner, etc.&lt;br /&gt;
&lt;br /&gt;
===Command: whereis===&lt;br /&gt;
The ‘whereis‘ command is used to locate the Binary, Sources and Manual Pages of the command. For example, to locate the Binary, Sources and Manual Pages of the command ‘ls‘ and ‘kill‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# whereis ls &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# whereis kill&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: This is useful to know where the binaries are installed for manual editing sometimes.&lt;br /&gt;
&lt;br /&gt;
===Command: service===&lt;br /&gt;
The ‘service‘ command controls the Starting, Stopping or Restarting of a ‘service‘. This command make it possible to start, restart or stop a service without restarting the system, for the changes to be taken into effect.&lt;br /&gt;
&lt;br /&gt;
Startting an apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# service apache2 start&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restarting a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# service apache2 restart&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stopping a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Stopping a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: All the process script lies in ‘/etc/init.d‘, and the path might needs to be included on certain system, i.e., in spite of running “service apache2 start” you would be asked to run “/etc/init.d/apache2 start”.&lt;br /&gt;
&lt;br /&gt;
===Command: alias===&lt;br /&gt;
alias is a built in shell command that lets you assign name for a long command or frequently used command.&lt;br /&gt;
For example.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
alias root=&#039;sudo -i&#039;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Command: df===&lt;br /&gt;
Report disk usages of file system. Useful for user as well as System Administrator to keep track of their disk usages. ‘df‘ works by examining directory entries, which generally are updated only when a file is closed.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# df&lt;br /&gt;
Filesystem     1K-blocks    Used Available Use% Mounted on&lt;br /&gt;
/dev/sda1       47929224 7811908  37675948  18% /&lt;br /&gt;
none                   4       0         4   0% /sys/fs/cgroup&lt;br /&gt;
udev             1005916       4   1005912   1% /dev&lt;br /&gt;
tmpfs             202824     816    202008   1% /run&lt;br /&gt;
none                5120       0      5120   0% /run/lock&lt;br /&gt;
none             1014120     628   1013492   1% /run/shm&lt;br /&gt;
none              102400      44    102356   1% /run/user&lt;br /&gt;
/dev/sda5         184307   79852     94727  46% /boot&lt;br /&gt;
/dev/sda7       95989516   61104  91045676   1% /data&lt;br /&gt;
/dev/sda8       91953192   57032  87218528   1% /personal&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Command: du===&lt;br /&gt;
Estimate file space usage. Output the summary of disk usages by ever file hierarchically, i.e., in recursive manner.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# du&lt;br /&gt;
308   ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/icons&lt;br /&gt;
344   ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop&lt;br /&gt;
4     ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/applet&lt;br /&gt;
548   ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/oblique-fonts&lt;br /&gt;
2048  ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/fonts&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: ‘df‘ only reports usage statistics on file systems, while ‘du‘, on the other hand, measures directory contents.&lt;br /&gt;
==Bash scripts==&lt;br /&gt;
&lt;br /&gt;
===Login Script===&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo su student2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if u run:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash --login&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if you login to a machine via ssh e.g:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@machine&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll be invoking ~/.profile Note that ~/.profile (or if not there, one of ~/.bash_profile or ~/.bash_login) normally contains relevant commands to run another script called ~/.bashrc (if said file exists):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if [ -f ~/.bashrc ]; then&lt;br /&gt;
    . ~/.bashrc&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121299</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121299"/>
		<updated>2017-05-07T15:24:11Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Using Bash for administrating */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
It is a powerful shell, and features, among other things:&lt;br /&gt;
&lt;br /&gt;
**Command line editing&lt;br /&gt;
**Command history&lt;br /&gt;
**A directory stack (pushd, popd)&lt;br /&gt;
**Command substitution&lt;br /&gt;
**Special variables, like $PPID&lt;br /&gt;
**Autocompletion&lt;br /&gt;
**In-process integer arithmetic: $((...))&lt;br /&gt;
**In-process regexes&lt;br /&gt;
**Aliases&lt;br /&gt;
**Functions&lt;br /&gt;
**Arrays&lt;br /&gt;
**Expansions: tilde, brace, variable&lt;br /&gt;
**Substring awesomeness&lt;br /&gt;
**Conditional expressions&lt;br /&gt;
**Security (restricted shell mode)&lt;br /&gt;
**Job Control&lt;br /&gt;
**Timing&lt;br /&gt;
**Prompt customization&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Using Bash for administrating=&lt;br /&gt;
==Useful commands==&lt;br /&gt;
===Command: find===&lt;br /&gt;
Search for files in the given directory, hierarchically starting at the parent directory and moving to sub-directories.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# find -name *.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: grep===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep user /etc/passwd &lt;br /&gt;
user:x:1000:1000:user,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Ignore word case and all other combination with ‘-i‘ option.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -i USER /etc/passwd &lt;br /&gt;
user:x:1000:1000:User,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Search recursively (-r) i.e. read all files under each directory for a string “127.0.0.1“.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -r &amp;quot;127.0.0.1&amp;quot; /etc/ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: man===&lt;br /&gt;
The ‘man‘ is the system’s manual pager. Man provides online documentation for all the possible options with a command and its usages. Almost all the command comes with their corresponding manual pages. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# man bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Manual page for man page itself, similarly ‘man cat‘ (Manual page for cat command) and ‘man ls‘ (Manual page for command ls).&lt;br /&gt;
&lt;br /&gt;
===Command: ps===&lt;br /&gt;
ps (Process) gives the status of running processes with a unique Id called PID.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
To list status of all the processes along with process id and PID, use option ‘-A‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: This command is very useful when you want to know which processes are running or may need PID sometimes, for process to be killed. You can use it with ‘grep‘ command to find customised output. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i ssh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Here ‘ps‘ is pipelined with ‘grep‘ command to find customised and relevant output of our need.&lt;br /&gt;
&lt;br /&gt;
===Command: kill===&lt;br /&gt;
You need a process’s pid (ps) to kill it.&lt;br /&gt;
Let suppose you want to kill program ‘apache2‘ that might not be responding. Run ‘ps -A‘ along with grep command.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i apache2&lt;br /&gt;
1285 ?        00:00:00 apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Find process ‘apache2‘, note its pid and kill it. For example, in that case ‘apache2‘ pid is ‘1285‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# kill 1285 (to kill the process apache2)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Every time you re-run a process or start a system, a new pid is generated for each process and you can know about the current running processes and its pid using command ‘ps‘.&lt;br /&gt;
Another way to kill the same process is.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# pkill apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Kill requires job id / process id for sending signals, where as in pkill, you have an option of using pattern, specifying process owner, etc.&lt;br /&gt;
&lt;br /&gt;
===Command: whereis===&lt;br /&gt;
The ‘whereis‘ command is used to locate the Binary, Sources and Manual Pages of the command. For example, to locate the Binary, Sources and Manual Pages of the command ‘ls‘ and ‘kill‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# whereis ls &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# whereis kill&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: This is useful to know where the binaries are installed for manual editing sometimes.&lt;br /&gt;
&lt;br /&gt;
===Command: service===&lt;br /&gt;
The ‘service‘ command controls the Starting, Stopping or Restarting of a ‘service‘. This command make it possible to start, restart or stop a service without restarting the system, for the changes to be taken into effect.&lt;br /&gt;
&lt;br /&gt;
Startting an apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# service apache2 start&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restarting a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# service apache2 restart&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stopping a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Stopping a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: All the process script lies in ‘/etc/init.d‘, and the path might needs to be included on certain system, i.e., in spite of running “service apache2 start” you would be asked to run “/etc/init.d/apache2 start”.&lt;br /&gt;
&lt;br /&gt;
===Command: alias===&lt;br /&gt;
alias is a built in shell command that lets you assign name for a long command or frequently used command.&lt;br /&gt;
For example.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
alias root=&#039;sudo -i&#039;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Command: df===&lt;br /&gt;
Report disk usages of file system. Useful for user as well as System Administrator to keep track of their disk usages. ‘df‘ works by examining directory entries, which generally are updated only when a file is closed.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# df&lt;br /&gt;
Filesystem     1K-blocks    Used Available Use% Mounted on&lt;br /&gt;
/dev/sda1       47929224 7811908  37675948  18% /&lt;br /&gt;
none                   4       0         4   0% /sys/fs/cgroup&lt;br /&gt;
udev             1005916       4   1005912   1% /dev&lt;br /&gt;
tmpfs             202824     816    202008   1% /run&lt;br /&gt;
none                5120       0      5120   0% /run/lock&lt;br /&gt;
none             1014120     628   1013492   1% /run/shm&lt;br /&gt;
none              102400      44    102356   1% /run/user&lt;br /&gt;
/dev/sda5         184307   79852     94727  46% /boot&lt;br /&gt;
/dev/sda7       95989516   61104  91045676   1% /data&lt;br /&gt;
/dev/sda8       91953192   57032  87218528   1% /personal&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Command: du===&lt;br /&gt;
Estimate file space usage. Output the summary of disk usages by ever file hierarchically, i.e., in recursive manner.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# du&lt;br /&gt;
308   ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/icons&lt;br /&gt;
344   ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop&lt;br /&gt;
4     ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/applet&lt;br /&gt;
548   ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/oblique-fonts&lt;br /&gt;
2048  ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/fonts&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: ‘df‘ only reports usage statistics on file systems, while ‘du‘, on the other hand, measures directory contents.&lt;br /&gt;
===Bash scripts===&lt;br /&gt;
===Login Script===&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo su student2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if u run:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash --login&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if you login to a machine via ssh e.g:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@machine&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll be invoking ~/.profile Note that ~/.profile (or if not there, one of ~/.bash_profile or ~/.bash_login) normally contains relevant commands to run another script called ~/.bashrc (if said file exists):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if [ -f ~/.bashrc ]; then&lt;br /&gt;
    . ~/.bashrc&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121298</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121298"/>
		<updated>2017-05-07T15:21:25Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Command: du */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
It is a powerful shell, and features, among other things:&lt;br /&gt;
&lt;br /&gt;
**Command line editing&lt;br /&gt;
**Command history&lt;br /&gt;
**A directory stack (pushd, popd)&lt;br /&gt;
**Command substitution&lt;br /&gt;
**Special variables, like $PPID&lt;br /&gt;
**Autocompletion&lt;br /&gt;
**In-process integer arithmetic: $((...))&lt;br /&gt;
**In-process regexes&lt;br /&gt;
**Aliases&lt;br /&gt;
**Functions&lt;br /&gt;
**Arrays&lt;br /&gt;
**Expansions: tilde, brace, variable&lt;br /&gt;
**Substring awesomeness&lt;br /&gt;
**Conditional expressions&lt;br /&gt;
**Security (restricted shell mode)&lt;br /&gt;
**Job Control&lt;br /&gt;
**Timing&lt;br /&gt;
**Prompt customization&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Using Bash for administrating=&lt;br /&gt;
===Command: find===&lt;br /&gt;
Search for files in the given directory, hierarchically starting at the parent directory and moving to sub-directories.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# find -name *.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: grep===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep user /etc/passwd &lt;br /&gt;
user:x:1000:1000:user,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Ignore word case and all other combination with ‘-i‘ option.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -i USER /etc/passwd &lt;br /&gt;
user:x:1000:1000:User,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Search recursively (-r) i.e. read all files under each directory for a string “127.0.0.1“.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -r &amp;quot;127.0.0.1&amp;quot; /etc/ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: man===&lt;br /&gt;
The ‘man‘ is the system’s manual pager. Man provides online documentation for all the possible options with a command and its usages. Almost all the command comes with their corresponding manual pages. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# man bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Manual page for man page itself, similarly ‘man cat‘ (Manual page for cat command) and ‘man ls‘ (Manual page for command ls).&lt;br /&gt;
&lt;br /&gt;
===Command: ps===&lt;br /&gt;
ps (Process) gives the status of running processes with a unique Id called PID.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
To list status of all the processes along with process id and PID, use option ‘-A‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: This command is very useful when you want to know which processes are running or may need PID sometimes, for process to be killed. You can use it with ‘grep‘ command to find customised output. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i ssh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Here ‘ps‘ is pipelined with ‘grep‘ command to find customised and relevant output of our need.&lt;br /&gt;
&lt;br /&gt;
===Command: kill===&lt;br /&gt;
You need a process’s pid (ps) to kill it.&lt;br /&gt;
Let suppose you want to kill program ‘apache2‘ that might not be responding. Run ‘ps -A‘ along with grep command.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i apache2&lt;br /&gt;
1285 ?        00:00:00 apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Find process ‘apache2‘, note its pid and kill it. For example, in that case ‘apache2‘ pid is ‘1285‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# kill 1285 (to kill the process apache2)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Every time you re-run a process or start a system, a new pid is generated for each process and you can know about the current running processes and its pid using command ‘ps‘.&lt;br /&gt;
Another way to kill the same process is.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# pkill apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Kill requires job id / process id for sending signals, where as in pkill, you have an option of using pattern, specifying process owner, etc.&lt;br /&gt;
&lt;br /&gt;
===Command: whereis===&lt;br /&gt;
The ‘whereis‘ command is used to locate the Binary, Sources and Manual Pages of the command. For example, to locate the Binary, Sources and Manual Pages of the command ‘ls‘ and ‘kill‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# whereis ls &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# whereis kill&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: This is useful to know where the binaries are installed for manual editing sometimes.&lt;br /&gt;
&lt;br /&gt;
===Command: service===&lt;br /&gt;
The ‘service‘ command controls the Starting, Stopping or Restarting of a ‘service‘. This command make it possible to start, restart or stop a service without restarting the system, for the changes to be taken into effect.&lt;br /&gt;
&lt;br /&gt;
Startting an apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# service apache2 start&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restarting a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# service apache2 restart&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stopping a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Stopping a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: All the process script lies in ‘/etc/init.d‘, and the path might needs to be included on certain system, i.e., in spite of running “service apache2 start” you would be asked to run “/etc/init.d/apache2 start”.&lt;br /&gt;
&lt;br /&gt;
===Command: alias===&lt;br /&gt;
alias is a built in shell command that lets you assign name for a long command or frequently used command.&lt;br /&gt;
For example.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
alias root=&#039;sudo -i&#039;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Command: df===&lt;br /&gt;
Report disk usages of file system. Useful for user as well as System Administrator to keep track of their disk usages. ‘df‘ works by examining directory entries, which generally are updated only when a file is closed.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# df&lt;br /&gt;
Filesystem     1K-blocks    Used Available Use% Mounted on&lt;br /&gt;
/dev/sda1       47929224 7811908  37675948  18% /&lt;br /&gt;
none                   4       0         4   0% /sys/fs/cgroup&lt;br /&gt;
udev             1005916       4   1005912   1% /dev&lt;br /&gt;
tmpfs             202824     816    202008   1% /run&lt;br /&gt;
none                5120       0      5120   0% /run/lock&lt;br /&gt;
none             1014120     628   1013492   1% /run/shm&lt;br /&gt;
none              102400      44    102356   1% /run/user&lt;br /&gt;
/dev/sda5         184307   79852     94727  46% /boot&lt;br /&gt;
/dev/sda7       95989516   61104  91045676   1% /data&lt;br /&gt;
/dev/sda8       91953192   57032  87218528   1% /personal&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Command: du===&lt;br /&gt;
Estimate file space usage. Output the summary of disk usages by ever file hierarchically, i.e., in recursive manner.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# du&lt;br /&gt;
308   ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/icons&lt;br /&gt;
344   ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop&lt;br /&gt;
4     ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/applet&lt;br /&gt;
548   ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/oblique-fonts&lt;br /&gt;
2048  ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/fonts&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: ‘df‘ only reports usage statistics on file systems, while ‘du‘, on the other hand, measures directory contents.&lt;br /&gt;
&lt;br /&gt;
==Login Script==&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo su student2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if u run:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash --login&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if you login to a machine via ssh e.g:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@machine&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll be invoking ~/.profile Note that ~/.profile (or if not there, one of ~/.bash_profile or ~/.bash_login) normally contains relevant commands to run another script called ~/.bashrc (if said file exists):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if [ -f ~/.bashrc ]; then&lt;br /&gt;
    . ~/.bashrc&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121297</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121297"/>
		<updated>2017-05-07T15:21:09Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Command: du */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
It is a powerful shell, and features, among other things:&lt;br /&gt;
&lt;br /&gt;
**Command line editing&lt;br /&gt;
**Command history&lt;br /&gt;
**A directory stack (pushd, popd)&lt;br /&gt;
**Command substitution&lt;br /&gt;
**Special variables, like $PPID&lt;br /&gt;
**Autocompletion&lt;br /&gt;
**In-process integer arithmetic: $((...))&lt;br /&gt;
**In-process regexes&lt;br /&gt;
**Aliases&lt;br /&gt;
**Functions&lt;br /&gt;
**Arrays&lt;br /&gt;
**Expansions: tilde, brace, variable&lt;br /&gt;
**Substring awesomeness&lt;br /&gt;
**Conditional expressions&lt;br /&gt;
**Security (restricted shell mode)&lt;br /&gt;
**Job Control&lt;br /&gt;
**Timing&lt;br /&gt;
**Prompt customization&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Using Bash for administrating=&lt;br /&gt;
===Command: find===&lt;br /&gt;
Search for files in the given directory, hierarchically starting at the parent directory and moving to sub-directories.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# find -name *.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: grep===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep user /etc/passwd &lt;br /&gt;
user:x:1000:1000:user,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Ignore word case and all other combination with ‘-i‘ option.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -i USER /etc/passwd &lt;br /&gt;
user:x:1000:1000:User,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Search recursively (-r) i.e. read all files under each directory for a string “127.0.0.1“.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -r &amp;quot;127.0.0.1&amp;quot; /etc/ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: man===&lt;br /&gt;
The ‘man‘ is the system’s manual pager. Man provides online documentation for all the possible options with a command and its usages. Almost all the command comes with their corresponding manual pages. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# man bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Manual page for man page itself, similarly ‘man cat‘ (Manual page for cat command) and ‘man ls‘ (Manual page for command ls).&lt;br /&gt;
&lt;br /&gt;
===Command: ps===&lt;br /&gt;
ps (Process) gives the status of running processes with a unique Id called PID.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
To list status of all the processes along with process id and PID, use option ‘-A‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: This command is very useful when you want to know which processes are running or may need PID sometimes, for process to be killed. You can use it with ‘grep‘ command to find customised output. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i ssh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Here ‘ps‘ is pipelined with ‘grep‘ command to find customised and relevant output of our need.&lt;br /&gt;
&lt;br /&gt;
===Command: kill===&lt;br /&gt;
You need a process’s pid (ps) to kill it.&lt;br /&gt;
Let suppose you want to kill program ‘apache2‘ that might not be responding. Run ‘ps -A‘ along with grep command.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i apache2&lt;br /&gt;
1285 ?        00:00:00 apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Find process ‘apache2‘, note its pid and kill it. For example, in that case ‘apache2‘ pid is ‘1285‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# kill 1285 (to kill the process apache2)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Every time you re-run a process or start a system, a new pid is generated for each process and you can know about the current running processes and its pid using command ‘ps‘.&lt;br /&gt;
Another way to kill the same process is.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# pkill apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Kill requires job id / process id for sending signals, where as in pkill, you have an option of using pattern, specifying process owner, etc.&lt;br /&gt;
&lt;br /&gt;
===Command: whereis===&lt;br /&gt;
The ‘whereis‘ command is used to locate the Binary, Sources and Manual Pages of the command. For example, to locate the Binary, Sources and Manual Pages of the command ‘ls‘ and ‘kill‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# whereis ls &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# whereis kill&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: This is useful to know where the binaries are installed for manual editing sometimes.&lt;br /&gt;
&lt;br /&gt;
===Command: service===&lt;br /&gt;
The ‘service‘ command controls the Starting, Stopping or Restarting of a ‘service‘. This command make it possible to start, restart or stop a service without restarting the system, for the changes to be taken into effect.&lt;br /&gt;
&lt;br /&gt;
Startting an apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# service apache2 start&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restarting a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# service apache2 restart&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stopping a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Stopping a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: All the process script lies in ‘/etc/init.d‘, and the path might needs to be included on certain system, i.e., in spite of running “service apache2 start” you would be asked to run “/etc/init.d/apache2 start”.&lt;br /&gt;
&lt;br /&gt;
===Command: alias===&lt;br /&gt;
alias is a built in shell command that lets you assign name for a long command or frequently used command.&lt;br /&gt;
For example.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
alias root=&#039;sudo -i&#039;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Command: df===&lt;br /&gt;
Report disk usages of file system. Useful for user as well as System Administrator to keep track of their disk usages. ‘df‘ works by examining directory entries, which generally are updated only when a file is closed.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# df&lt;br /&gt;
Filesystem     1K-blocks    Used Available Use% Mounted on&lt;br /&gt;
/dev/sda1       47929224 7811908  37675948  18% /&lt;br /&gt;
none                   4       0         4   0% /sys/fs/cgroup&lt;br /&gt;
udev             1005916       4   1005912   1% /dev&lt;br /&gt;
tmpfs             202824     816    202008   1% /run&lt;br /&gt;
none                5120       0      5120   0% /run/lock&lt;br /&gt;
none             1014120     628   1013492   1% /run/shm&lt;br /&gt;
none              102400      44    102356   1% /run/user&lt;br /&gt;
/dev/sda5         184307   79852     94727  46% /boot&lt;br /&gt;
/dev/sda7       95989516   61104  91045676   1% /data&lt;br /&gt;
/dev/sda8       91953192   57032  87218528   1% /personal&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Command: du===&lt;br /&gt;
Estimate file space usage. Output the summary of disk usages by ever file hierarchically, i.e., in recursive manner.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# du&lt;br /&gt;
308       ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/icons&lt;br /&gt;
344       ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop&lt;br /&gt;
4         ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/applet&lt;br /&gt;
548       ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/oblique-fonts&lt;br /&gt;
2048      ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/fonts&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: ‘df‘ only reports usage statistics on file systems, while ‘du‘, on the other hand, measures directory contents.&lt;br /&gt;
&lt;br /&gt;
==Login Script==&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo su student2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if u run:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash --login&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if you login to a machine via ssh e.g:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@machine&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll be invoking ~/.profile Note that ~/.profile (or if not there, one of ~/.bash_profile or ~/.bash_login) normally contains relevant commands to run another script called ~/.bashrc (if said file exists):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if [ -f ~/.bashrc ]; then&lt;br /&gt;
    . ~/.bashrc&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121296</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121296"/>
		<updated>2017-05-07T15:20:41Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Command: du */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
It is a powerful shell, and features, among other things:&lt;br /&gt;
&lt;br /&gt;
**Command line editing&lt;br /&gt;
**Command history&lt;br /&gt;
**A directory stack (pushd, popd)&lt;br /&gt;
**Command substitution&lt;br /&gt;
**Special variables, like $PPID&lt;br /&gt;
**Autocompletion&lt;br /&gt;
**In-process integer arithmetic: $((...))&lt;br /&gt;
**In-process regexes&lt;br /&gt;
**Aliases&lt;br /&gt;
**Functions&lt;br /&gt;
**Arrays&lt;br /&gt;
**Expansions: tilde, brace, variable&lt;br /&gt;
**Substring awesomeness&lt;br /&gt;
**Conditional expressions&lt;br /&gt;
**Security (restricted shell mode)&lt;br /&gt;
**Job Control&lt;br /&gt;
**Timing&lt;br /&gt;
**Prompt customization&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Using Bash for administrating=&lt;br /&gt;
===Command: find===&lt;br /&gt;
Search for files in the given directory, hierarchically starting at the parent directory and moving to sub-directories.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# find -name *.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: grep===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep user /etc/passwd &lt;br /&gt;
user:x:1000:1000:user,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Ignore word case and all other combination with ‘-i‘ option.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -i USER /etc/passwd &lt;br /&gt;
user:x:1000:1000:User,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Search recursively (-r) i.e. read all files under each directory for a string “127.0.0.1“.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -r &amp;quot;127.0.0.1&amp;quot; /etc/ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: man===&lt;br /&gt;
The ‘man‘ is the system’s manual pager. Man provides online documentation for all the possible options with a command and its usages. Almost all the command comes with their corresponding manual pages. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# man bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Manual page for man page itself, similarly ‘man cat‘ (Manual page for cat command) and ‘man ls‘ (Manual page for command ls).&lt;br /&gt;
&lt;br /&gt;
===Command: ps===&lt;br /&gt;
ps (Process) gives the status of running processes with a unique Id called PID.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
To list status of all the processes along with process id and PID, use option ‘-A‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: This command is very useful when you want to know which processes are running or may need PID sometimes, for process to be killed. You can use it with ‘grep‘ command to find customised output. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i ssh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Here ‘ps‘ is pipelined with ‘grep‘ command to find customised and relevant output of our need.&lt;br /&gt;
&lt;br /&gt;
===Command: kill===&lt;br /&gt;
You need a process’s pid (ps) to kill it.&lt;br /&gt;
Let suppose you want to kill program ‘apache2‘ that might not be responding. Run ‘ps -A‘ along with grep command.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i apache2&lt;br /&gt;
1285 ?        00:00:00 apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Find process ‘apache2‘, note its pid and kill it. For example, in that case ‘apache2‘ pid is ‘1285‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# kill 1285 (to kill the process apache2)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Every time you re-run a process or start a system, a new pid is generated for each process and you can know about the current running processes and its pid using command ‘ps‘.&lt;br /&gt;
Another way to kill the same process is.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# pkill apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Kill requires job id / process id for sending signals, where as in pkill, you have an option of using pattern, specifying process owner, etc.&lt;br /&gt;
&lt;br /&gt;
===Command: whereis===&lt;br /&gt;
The ‘whereis‘ command is used to locate the Binary, Sources and Manual Pages of the command. For example, to locate the Binary, Sources and Manual Pages of the command ‘ls‘ and ‘kill‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# whereis ls &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# whereis kill&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: This is useful to know where the binaries are installed for manual editing sometimes.&lt;br /&gt;
&lt;br /&gt;
===Command: service===&lt;br /&gt;
The ‘service‘ command controls the Starting, Stopping or Restarting of a ‘service‘. This command make it possible to start, restart or stop a service without restarting the system, for the changes to be taken into effect.&lt;br /&gt;
&lt;br /&gt;
Startting an apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# service apache2 start&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restarting a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# service apache2 restart&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stopping a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Stopping a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: All the process script lies in ‘/etc/init.d‘, and the path might needs to be included on certain system, i.e., in spite of running “service apache2 start” you would be asked to run “/etc/init.d/apache2 start”.&lt;br /&gt;
&lt;br /&gt;
===Command: alias===&lt;br /&gt;
alias is a built in shell command that lets you assign name for a long command or frequently used command.&lt;br /&gt;
For example.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
alias root=&#039;sudo -i&#039;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Command: df===&lt;br /&gt;
Report disk usages of file system. Useful for user as well as System Administrator to keep track of their disk usages. ‘df‘ works by examining directory entries, which generally are updated only when a file is closed.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# df&lt;br /&gt;
Filesystem     1K-blocks    Used Available Use% Mounted on&lt;br /&gt;
/dev/sda1       47929224 7811908  37675948  18% /&lt;br /&gt;
none                   4       0         4   0% /sys/fs/cgroup&lt;br /&gt;
udev             1005916       4   1005912   1% /dev&lt;br /&gt;
tmpfs             202824     816    202008   1% /run&lt;br /&gt;
none                5120       0      5120   0% /run/lock&lt;br /&gt;
none             1014120     628   1013492   1% /run/shm&lt;br /&gt;
none              102400      44    102356   1% /run/user&lt;br /&gt;
/dev/sda5         184307   79852     94727  46% /boot&lt;br /&gt;
/dev/sda7       95989516   61104  91045676   1% /data&lt;br /&gt;
/dev/sda8       91953192   57032  87218528   1% /personal&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Command: du===&lt;br /&gt;
Estimate file space usage. Output the summary of disk usages by ever file hierarchically, i.e., in recursive manner.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
308       ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/icons&lt;br /&gt;
344       ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop&lt;br /&gt;
4         ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/applet&lt;br /&gt;
548       ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/oblique-fonts&lt;br /&gt;
2048      ./.local/share/Trash/files/jdk1.8.0_121/jre/lib/desktop/fonts&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: ‘df‘ only reports usage statistics on file systems, while ‘du‘, on the other hand, measures directory contents.&lt;br /&gt;
&lt;br /&gt;
==Login Script==&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo su student2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if u run:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash --login&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if you login to a machine via ssh e.g:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@machine&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll be invoking ~/.profile Note that ~/.profile (or if not there, one of ~/.bash_profile or ~/.bash_login) normally contains relevant commands to run another script called ~/.bashrc (if said file exists):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if [ -f ~/.bashrc ]; then&lt;br /&gt;
    . ~/.bashrc&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121295</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121295"/>
		<updated>2017-05-07T15:17:24Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Command: df */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
It is a powerful shell, and features, among other things:&lt;br /&gt;
&lt;br /&gt;
**Command line editing&lt;br /&gt;
**Command history&lt;br /&gt;
**A directory stack (pushd, popd)&lt;br /&gt;
**Command substitution&lt;br /&gt;
**Special variables, like $PPID&lt;br /&gt;
**Autocompletion&lt;br /&gt;
**In-process integer arithmetic: $((...))&lt;br /&gt;
**In-process regexes&lt;br /&gt;
**Aliases&lt;br /&gt;
**Functions&lt;br /&gt;
**Arrays&lt;br /&gt;
**Expansions: tilde, brace, variable&lt;br /&gt;
**Substring awesomeness&lt;br /&gt;
**Conditional expressions&lt;br /&gt;
**Security (restricted shell mode)&lt;br /&gt;
**Job Control&lt;br /&gt;
**Timing&lt;br /&gt;
**Prompt customization&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Using Bash for administrating=&lt;br /&gt;
===Command: find===&lt;br /&gt;
Search for files in the given directory, hierarchically starting at the parent directory and moving to sub-directories.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# find -name *.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: grep===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep user /etc/passwd &lt;br /&gt;
user:x:1000:1000:user,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Ignore word case and all other combination with ‘-i‘ option.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -i USER /etc/passwd &lt;br /&gt;
user:x:1000:1000:User,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Search recursively (-r) i.e. read all files under each directory for a string “127.0.0.1“.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -r &amp;quot;127.0.0.1&amp;quot; /etc/ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: man===&lt;br /&gt;
The ‘man‘ is the system’s manual pager. Man provides online documentation for all the possible options with a command and its usages. Almost all the command comes with their corresponding manual pages. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# man bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Manual page for man page itself, similarly ‘man cat‘ (Manual page for cat command) and ‘man ls‘ (Manual page for command ls).&lt;br /&gt;
&lt;br /&gt;
===Command: ps===&lt;br /&gt;
ps (Process) gives the status of running processes with a unique Id called PID.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
To list status of all the processes along with process id and PID, use option ‘-A‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: This command is very useful when you want to know which processes are running or may need PID sometimes, for process to be killed. You can use it with ‘grep‘ command to find customised output. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i ssh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Here ‘ps‘ is pipelined with ‘grep‘ command to find customised and relevant output of our need.&lt;br /&gt;
&lt;br /&gt;
===Command: kill===&lt;br /&gt;
You need a process’s pid (ps) to kill it.&lt;br /&gt;
Let suppose you want to kill program ‘apache2‘ that might not be responding. Run ‘ps -A‘ along with grep command.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i apache2&lt;br /&gt;
1285 ?        00:00:00 apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Find process ‘apache2‘, note its pid and kill it. For example, in that case ‘apache2‘ pid is ‘1285‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# kill 1285 (to kill the process apache2)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Every time you re-run a process or start a system, a new pid is generated for each process and you can know about the current running processes and its pid using command ‘ps‘.&lt;br /&gt;
Another way to kill the same process is.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# pkill apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Kill requires job id / process id for sending signals, where as in pkill, you have an option of using pattern, specifying process owner, etc.&lt;br /&gt;
&lt;br /&gt;
===Command: whereis===&lt;br /&gt;
The ‘whereis‘ command is used to locate the Binary, Sources and Manual Pages of the command. For example, to locate the Binary, Sources and Manual Pages of the command ‘ls‘ and ‘kill‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# whereis ls &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# whereis kill&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: This is useful to know where the binaries are installed for manual editing sometimes.&lt;br /&gt;
&lt;br /&gt;
===Command: service===&lt;br /&gt;
The ‘service‘ command controls the Starting, Stopping or Restarting of a ‘service‘. This command make it possible to start, restart or stop a service without restarting the system, for the changes to be taken into effect.&lt;br /&gt;
&lt;br /&gt;
Startting an apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# service apache2 start&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restarting a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# service apache2 restart&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stopping a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Stopping a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: All the process script lies in ‘/etc/init.d‘, and the path might needs to be included on certain system, i.e., in spite of running “service apache2 start” you would be asked to run “/etc/init.d/apache2 start”.&lt;br /&gt;
&lt;br /&gt;
===Command: alias===&lt;br /&gt;
alias is a built in shell command that lets you assign name for a long command or frequently used command.&lt;br /&gt;
For example.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
alias root=&#039;sudo -i&#039;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Command: df===&lt;br /&gt;
Report disk usages of file system. Useful for user as well as System Administrator to keep track of their disk usages. ‘df‘ works by examining directory entries, which generally are updated only when a file is closed.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# df&lt;br /&gt;
Filesystem     1K-blocks    Used Available Use% Mounted on&lt;br /&gt;
/dev/sda1       47929224 7811908  37675948  18% /&lt;br /&gt;
none                   4       0         4   0% /sys/fs/cgroup&lt;br /&gt;
udev             1005916       4   1005912   1% /dev&lt;br /&gt;
tmpfs             202824     816    202008   1% /run&lt;br /&gt;
none                5120       0      5120   0% /run/lock&lt;br /&gt;
none             1014120     628   1013492   1% /run/shm&lt;br /&gt;
none              102400      44    102356   1% /run/user&lt;br /&gt;
/dev/sda5         184307   79852     94727  46% /boot&lt;br /&gt;
/dev/sda7       95989516   61104  91045676   1% /data&lt;br /&gt;
/dev/sda8       91953192   57032  87218528   1% /personal&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Command: du===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Login Script==&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo su student2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if u run:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash --login&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if you login to a machine via ssh e.g:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@machine&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll be invoking ~/.profile Note that ~/.profile (or if not there, one of ~/.bash_profile or ~/.bash_login) normally contains relevant commands to run another script called ~/.bashrc (if said file exists):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if [ -f ~/.bashrc ]; then&lt;br /&gt;
    . ~/.bashrc&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121294</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121294"/>
		<updated>2017-05-07T15:16:11Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Command: alias */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
It is a powerful shell, and features, among other things:&lt;br /&gt;
&lt;br /&gt;
**Command line editing&lt;br /&gt;
**Command history&lt;br /&gt;
**A directory stack (pushd, popd)&lt;br /&gt;
**Command substitution&lt;br /&gt;
**Special variables, like $PPID&lt;br /&gt;
**Autocompletion&lt;br /&gt;
**In-process integer arithmetic: $((...))&lt;br /&gt;
**In-process regexes&lt;br /&gt;
**Aliases&lt;br /&gt;
**Functions&lt;br /&gt;
**Arrays&lt;br /&gt;
**Expansions: tilde, brace, variable&lt;br /&gt;
**Substring awesomeness&lt;br /&gt;
**Conditional expressions&lt;br /&gt;
**Security (restricted shell mode)&lt;br /&gt;
**Job Control&lt;br /&gt;
**Timing&lt;br /&gt;
**Prompt customization&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Using Bash for administrating=&lt;br /&gt;
===Command: find===&lt;br /&gt;
Search for files in the given directory, hierarchically starting at the parent directory and moving to sub-directories.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# find -name *.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: grep===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep user /etc/passwd &lt;br /&gt;
user:x:1000:1000:user,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Ignore word case and all other combination with ‘-i‘ option.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -i USER /etc/passwd &lt;br /&gt;
user:x:1000:1000:User,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Search recursively (-r) i.e. read all files under each directory for a string “127.0.0.1“.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -r &amp;quot;127.0.0.1&amp;quot; /etc/ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: man===&lt;br /&gt;
The ‘man‘ is the system’s manual pager. Man provides online documentation for all the possible options with a command and its usages. Almost all the command comes with their corresponding manual pages. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# man bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Manual page for man page itself, similarly ‘man cat‘ (Manual page for cat command) and ‘man ls‘ (Manual page for command ls).&lt;br /&gt;
&lt;br /&gt;
===Command: ps===&lt;br /&gt;
ps (Process) gives the status of running processes with a unique Id called PID.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
To list status of all the processes along with process id and PID, use option ‘-A‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: This command is very useful when you want to know which processes are running or may need PID sometimes, for process to be killed. You can use it with ‘grep‘ command to find customised output. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i ssh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Here ‘ps‘ is pipelined with ‘grep‘ command to find customised and relevant output of our need.&lt;br /&gt;
&lt;br /&gt;
===Command: kill===&lt;br /&gt;
You need a process’s pid (ps) to kill it.&lt;br /&gt;
Let suppose you want to kill program ‘apache2‘ that might not be responding. Run ‘ps -A‘ along with grep command.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i apache2&lt;br /&gt;
1285 ?        00:00:00 apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Find process ‘apache2‘, note its pid and kill it. For example, in that case ‘apache2‘ pid is ‘1285‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# kill 1285 (to kill the process apache2)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Every time you re-run a process or start a system, a new pid is generated for each process and you can know about the current running processes and its pid using command ‘ps‘.&lt;br /&gt;
Another way to kill the same process is.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# pkill apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Kill requires job id / process id for sending signals, where as in pkill, you have an option of using pattern, specifying process owner, etc.&lt;br /&gt;
&lt;br /&gt;
===Command: whereis===&lt;br /&gt;
The ‘whereis‘ command is used to locate the Binary, Sources and Manual Pages of the command. For example, to locate the Binary, Sources and Manual Pages of the command ‘ls‘ and ‘kill‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# whereis ls &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# whereis kill&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: This is useful to know where the binaries are installed for manual editing sometimes.&lt;br /&gt;
&lt;br /&gt;
===Command: service===&lt;br /&gt;
The ‘service‘ command controls the Starting, Stopping or Restarting of a ‘service‘. This command make it possible to start, restart or stop a service without restarting the system, for the changes to be taken into effect.&lt;br /&gt;
&lt;br /&gt;
Startting an apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# service apache2 start&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restarting a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# service apache2 restart&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stopping a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Stopping a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: All the process script lies in ‘/etc/init.d‘, and the path might needs to be included on certain system, i.e., in spite of running “service apache2 start” you would be asked to run “/etc/init.d/apache2 start”.&lt;br /&gt;
&lt;br /&gt;
===Command: alias===&lt;br /&gt;
alias is a built in shell command that lets you assign name for a long command or frequently used command.&lt;br /&gt;
For example.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
alias root=&#039;sudo -i&#039;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Command: df===&lt;br /&gt;
===Command: du===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Login Script==&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo su student2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if u run:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash --login&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if you login to a machine via ssh e.g:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@machine&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll be invoking ~/.profile Note that ~/.profile (or if not there, one of ~/.bash_profile or ~/.bash_login) normally contains relevant commands to run another script called ~/.bashrc (if said file exists):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if [ -f ~/.bashrc ]; then&lt;br /&gt;
    . ~/.bashrc&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121293</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121293"/>
		<updated>2017-05-07T15:11:21Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Command: service */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
It is a powerful shell, and features, among other things:&lt;br /&gt;
&lt;br /&gt;
**Command line editing&lt;br /&gt;
**Command history&lt;br /&gt;
**A directory stack (pushd, popd)&lt;br /&gt;
**Command substitution&lt;br /&gt;
**Special variables, like $PPID&lt;br /&gt;
**Autocompletion&lt;br /&gt;
**In-process integer arithmetic: $((...))&lt;br /&gt;
**In-process regexes&lt;br /&gt;
**Aliases&lt;br /&gt;
**Functions&lt;br /&gt;
**Arrays&lt;br /&gt;
**Expansions: tilde, brace, variable&lt;br /&gt;
**Substring awesomeness&lt;br /&gt;
**Conditional expressions&lt;br /&gt;
**Security (restricted shell mode)&lt;br /&gt;
**Job Control&lt;br /&gt;
**Timing&lt;br /&gt;
**Prompt customization&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Using Bash for administrating=&lt;br /&gt;
===Command: find===&lt;br /&gt;
Search for files in the given directory, hierarchically starting at the parent directory and moving to sub-directories.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# find -name *.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: grep===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep user /etc/passwd &lt;br /&gt;
user:x:1000:1000:user,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Ignore word case and all other combination with ‘-i‘ option.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -i USER /etc/passwd &lt;br /&gt;
user:x:1000:1000:User,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Search recursively (-r) i.e. read all files under each directory for a string “127.0.0.1“.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -r &amp;quot;127.0.0.1&amp;quot; /etc/ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: man===&lt;br /&gt;
The ‘man‘ is the system’s manual pager. Man provides online documentation for all the possible options with a command and its usages. Almost all the command comes with their corresponding manual pages. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# man bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Manual page for man page itself, similarly ‘man cat‘ (Manual page for cat command) and ‘man ls‘ (Manual page for command ls).&lt;br /&gt;
&lt;br /&gt;
===Command: ps===&lt;br /&gt;
ps (Process) gives the status of running processes with a unique Id called PID.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
To list status of all the processes along with process id and PID, use option ‘-A‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: This command is very useful when you want to know which processes are running or may need PID sometimes, for process to be killed. You can use it with ‘grep‘ command to find customised output. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i ssh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Here ‘ps‘ is pipelined with ‘grep‘ command to find customised and relevant output of our need.&lt;br /&gt;
&lt;br /&gt;
===Command: kill===&lt;br /&gt;
You need a process’s pid (ps) to kill it.&lt;br /&gt;
Let suppose you want to kill program ‘apache2‘ that might not be responding. Run ‘ps -A‘ along with grep command.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i apache2&lt;br /&gt;
1285 ?        00:00:00 apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Find process ‘apache2‘, note its pid and kill it. For example, in that case ‘apache2‘ pid is ‘1285‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# kill 1285 (to kill the process apache2)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Every time you re-run a process or start a system, a new pid is generated for each process and you can know about the current running processes and its pid using command ‘ps‘.&lt;br /&gt;
Another way to kill the same process is.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# pkill apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Kill requires job id / process id for sending signals, where as in pkill, you have an option of using pattern, specifying process owner, etc.&lt;br /&gt;
&lt;br /&gt;
===Command: whereis===&lt;br /&gt;
The ‘whereis‘ command is used to locate the Binary, Sources and Manual Pages of the command. For example, to locate the Binary, Sources and Manual Pages of the command ‘ls‘ and ‘kill‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# whereis ls &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# whereis kill&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: This is useful to know where the binaries are installed for manual editing sometimes.&lt;br /&gt;
&lt;br /&gt;
===Command: service===&lt;br /&gt;
The ‘service‘ command controls the Starting, Stopping or Restarting of a ‘service‘. This command make it possible to start, restart or stop a service without restarting the system, for the changes to be taken into effect.&lt;br /&gt;
&lt;br /&gt;
Startting an apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# service apache2 start&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restarting a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# service apache2 restart&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stopping a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Stopping a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: All the process script lies in ‘/etc/init.d‘, and the path might needs to be included on certain system, i.e., in spite of running “service apache2 start” you would be asked to run “/etc/init.d/apache2 start”.&lt;br /&gt;
&lt;br /&gt;
===Command: alias===&lt;br /&gt;
===Command: df===&lt;br /&gt;
===Command: du===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Login Script==&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo su student2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if u run:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash --login&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if you login to a machine via ssh e.g:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@machine&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll be invoking ~/.profile Note that ~/.profile (or if not there, one of ~/.bash_profile or ~/.bash_login) normally contains relevant commands to run another script called ~/.bashrc (if said file exists):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if [ -f ~/.bashrc ]; then&lt;br /&gt;
    . ~/.bashrc&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121292</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121292"/>
		<updated>2017-05-07T15:11:04Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Command: service */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
It is a powerful shell, and features, among other things:&lt;br /&gt;
&lt;br /&gt;
**Command line editing&lt;br /&gt;
**Command history&lt;br /&gt;
**A directory stack (pushd, popd)&lt;br /&gt;
**Command substitution&lt;br /&gt;
**Special variables, like $PPID&lt;br /&gt;
**Autocompletion&lt;br /&gt;
**In-process integer arithmetic: $((...))&lt;br /&gt;
**In-process regexes&lt;br /&gt;
**Aliases&lt;br /&gt;
**Functions&lt;br /&gt;
**Arrays&lt;br /&gt;
**Expansions: tilde, brace, variable&lt;br /&gt;
**Substring awesomeness&lt;br /&gt;
**Conditional expressions&lt;br /&gt;
**Security (restricted shell mode)&lt;br /&gt;
**Job Control&lt;br /&gt;
**Timing&lt;br /&gt;
**Prompt customization&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Using Bash for administrating=&lt;br /&gt;
===Command: find===&lt;br /&gt;
Search for files in the given directory, hierarchically starting at the parent directory and moving to sub-directories.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# find -name *.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: grep===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep user /etc/passwd &lt;br /&gt;
user:x:1000:1000:user,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Ignore word case and all other combination with ‘-i‘ option.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -i USER /etc/passwd &lt;br /&gt;
user:x:1000:1000:User,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Search recursively (-r) i.e. read all files under each directory for a string “127.0.0.1“.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -r &amp;quot;127.0.0.1&amp;quot; /etc/ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: man===&lt;br /&gt;
The ‘man‘ is the system’s manual pager. Man provides online documentation for all the possible options with a command and its usages. Almost all the command comes with their corresponding manual pages. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# man bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Manual page for man page itself, similarly ‘man cat‘ (Manual page for cat command) and ‘man ls‘ (Manual page for command ls).&lt;br /&gt;
&lt;br /&gt;
===Command: ps===&lt;br /&gt;
ps (Process) gives the status of running processes with a unique Id called PID.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
To list status of all the processes along with process id and PID, use option ‘-A‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: This command is very useful when you want to know which processes are running or may need PID sometimes, for process to be killed. You can use it with ‘grep‘ command to find customised output. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i ssh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Here ‘ps‘ is pipelined with ‘grep‘ command to find customised and relevant output of our need.&lt;br /&gt;
&lt;br /&gt;
===Command: kill===&lt;br /&gt;
You need a process’s pid (ps) to kill it.&lt;br /&gt;
Let suppose you want to kill program ‘apache2‘ that might not be responding. Run ‘ps -A‘ along with grep command.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i apache2&lt;br /&gt;
1285 ?        00:00:00 apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Find process ‘apache2‘, note its pid and kill it. For example, in that case ‘apache2‘ pid is ‘1285‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# kill 1285 (to kill the process apache2)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Every time you re-run a process or start a system, a new pid is generated for each process and you can know about the current running processes and its pid using command ‘ps‘.&lt;br /&gt;
Another way to kill the same process is.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# pkill apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Kill requires job id / process id for sending signals, where as in pkill, you have an option of using pattern, specifying process owner, etc.&lt;br /&gt;
&lt;br /&gt;
===Command: whereis===&lt;br /&gt;
The ‘whereis‘ command is used to locate the Binary, Sources and Manual Pages of the command. For example, to locate the Binary, Sources and Manual Pages of the command ‘ls‘ and ‘kill‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# whereis ls &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# whereis kill&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: This is useful to know where the binaries are installed for manual editing sometimes.&lt;br /&gt;
&lt;br /&gt;
===Command: service===&lt;br /&gt;
The ‘service‘ command controls the Starting, Stopping or Restarting of a ‘service‘. This command make it possible to start, restart or stop a service without restarting the system, for the changes to be taken into effect.&lt;br /&gt;
&lt;br /&gt;
Startting an apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# service apache2 start&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restarting a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# service apache2 restart&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Stopping a apache2 server on Ubuntu&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: All the process script lies in ‘/etc/init.d‘, and the path might needs to be included on certain system, i.e., in spite of running “service apache2 start” you would be asked to run “/etc/init.d/apache2 start”.&lt;br /&gt;
&lt;br /&gt;
===Command: alias===&lt;br /&gt;
===Command: df===&lt;br /&gt;
===Command: du===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Login Script==&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo su student2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if u run:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash --login&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if you login to a machine via ssh e.g:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@machine&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll be invoking ~/.profile Note that ~/.profile (or if not there, one of ~/.bash_profile or ~/.bash_login) normally contains relevant commands to run another script called ~/.bashrc (if said file exists):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if [ -f ~/.bashrc ]; then&lt;br /&gt;
    . ~/.bashrc&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121290</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121290"/>
		<updated>2017-05-07T15:07:37Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Command: whereis */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
It is a powerful shell, and features, among other things:&lt;br /&gt;
&lt;br /&gt;
**Command line editing&lt;br /&gt;
**Command history&lt;br /&gt;
**A directory stack (pushd, popd)&lt;br /&gt;
**Command substitution&lt;br /&gt;
**Special variables, like $PPID&lt;br /&gt;
**Autocompletion&lt;br /&gt;
**In-process integer arithmetic: $((...))&lt;br /&gt;
**In-process regexes&lt;br /&gt;
**Aliases&lt;br /&gt;
**Functions&lt;br /&gt;
**Arrays&lt;br /&gt;
**Expansions: tilde, brace, variable&lt;br /&gt;
**Substring awesomeness&lt;br /&gt;
**Conditional expressions&lt;br /&gt;
**Security (restricted shell mode)&lt;br /&gt;
**Job Control&lt;br /&gt;
**Timing&lt;br /&gt;
**Prompt customization&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Using Bash for administrating=&lt;br /&gt;
===Command: find===&lt;br /&gt;
Search for files in the given directory, hierarchically starting at the parent directory and moving to sub-directories.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# find -name *.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: grep===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep user /etc/passwd &lt;br /&gt;
user:x:1000:1000:user,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Ignore word case and all other combination with ‘-i‘ option.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -i USER /etc/passwd &lt;br /&gt;
user:x:1000:1000:User,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Search recursively (-r) i.e. read all files under each directory for a string “127.0.0.1“.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -r &amp;quot;127.0.0.1&amp;quot; /etc/ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: man===&lt;br /&gt;
The ‘man‘ is the system’s manual pager. Man provides online documentation for all the possible options with a command and its usages. Almost all the command comes with their corresponding manual pages. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# man bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Manual page for man page itself, similarly ‘man cat‘ (Manual page for cat command) and ‘man ls‘ (Manual page for command ls).&lt;br /&gt;
&lt;br /&gt;
===Command: ps===&lt;br /&gt;
ps (Process) gives the status of running processes with a unique Id called PID.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
To list status of all the processes along with process id and PID, use option ‘-A‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: This command is very useful when you want to know which processes are running or may need PID sometimes, for process to be killed. You can use it with ‘grep‘ command to find customised output. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i ssh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Here ‘ps‘ is pipelined with ‘grep‘ command to find customised and relevant output of our need.&lt;br /&gt;
&lt;br /&gt;
===Command: kill===&lt;br /&gt;
You need a process’s pid (ps) to kill it.&lt;br /&gt;
Let suppose you want to kill program ‘apache2‘ that might not be responding. Run ‘ps -A‘ along with grep command.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i apache2&lt;br /&gt;
1285 ?        00:00:00 apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Find process ‘apache2‘, note its pid and kill it. For example, in that case ‘apache2‘ pid is ‘1285‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# kill 1285 (to kill the process apache2)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Every time you re-run a process or start a system, a new pid is generated for each process and you can know about the current running processes and its pid using command ‘ps‘.&lt;br /&gt;
Another way to kill the same process is.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# pkill apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Kill requires job id / process id for sending signals, where as in pkill, you have an option of using pattern, specifying process owner, etc.&lt;br /&gt;
&lt;br /&gt;
===Command: whereis===&lt;br /&gt;
The ‘whereis‘ command is used to locate the Binary, Sources and Manual Pages of the command. For example, to locate the Binary, Sources and Manual Pages of the command ‘ls‘ and ‘kill‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# whereis ls &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# whereis kill&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: This is useful to know where the binaries are installed for manual editing sometimes.&lt;br /&gt;
&lt;br /&gt;
===Command: service===&lt;br /&gt;
===Command: alias===&lt;br /&gt;
===Command: df===&lt;br /&gt;
===Command: du===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Login Script==&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo su student2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if u run:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash --login&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if you login to a machine via ssh e.g:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@machine&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll be invoking ~/.profile Note that ~/.profile (or if not there, one of ~/.bash_profile or ~/.bash_login) normally contains relevant commands to run another script called ~/.bashrc (if said file exists):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if [ -f ~/.bashrc ]; then&lt;br /&gt;
    . ~/.bashrc&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121289</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121289"/>
		<updated>2017-05-07T15:05:23Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Command: kill */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
It is a powerful shell, and features, among other things:&lt;br /&gt;
&lt;br /&gt;
**Command line editing&lt;br /&gt;
**Command history&lt;br /&gt;
**A directory stack (pushd, popd)&lt;br /&gt;
**Command substitution&lt;br /&gt;
**Special variables, like $PPID&lt;br /&gt;
**Autocompletion&lt;br /&gt;
**In-process integer arithmetic: $((...))&lt;br /&gt;
**In-process regexes&lt;br /&gt;
**Aliases&lt;br /&gt;
**Functions&lt;br /&gt;
**Arrays&lt;br /&gt;
**Expansions: tilde, brace, variable&lt;br /&gt;
**Substring awesomeness&lt;br /&gt;
**Conditional expressions&lt;br /&gt;
**Security (restricted shell mode)&lt;br /&gt;
**Job Control&lt;br /&gt;
**Timing&lt;br /&gt;
**Prompt customization&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Using Bash for administrating=&lt;br /&gt;
===Command: find===&lt;br /&gt;
Search for files in the given directory, hierarchically starting at the parent directory and moving to sub-directories.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# find -name *.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: grep===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep user /etc/passwd &lt;br /&gt;
user:x:1000:1000:user,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Ignore word case and all other combination with ‘-i‘ option.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -i USER /etc/passwd &lt;br /&gt;
user:x:1000:1000:User,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Search recursively (-r) i.e. read all files under each directory for a string “127.0.0.1“.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -r &amp;quot;127.0.0.1&amp;quot; /etc/ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: man===&lt;br /&gt;
The ‘man‘ is the system’s manual pager. Man provides online documentation for all the possible options with a command and its usages. Almost all the command comes with their corresponding manual pages. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# man bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Manual page for man page itself, similarly ‘man cat‘ (Manual page for cat command) and ‘man ls‘ (Manual page for command ls).&lt;br /&gt;
&lt;br /&gt;
===Command: ps===&lt;br /&gt;
ps (Process) gives the status of running processes with a unique Id called PID.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
To list status of all the processes along with process id and PID, use option ‘-A‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: This command is very useful when you want to know which processes are running or may need PID sometimes, for process to be killed. You can use it with ‘grep‘ command to find customised output. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i ssh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Here ‘ps‘ is pipelined with ‘grep‘ command to find customised and relevant output of our need.&lt;br /&gt;
&lt;br /&gt;
===Command: kill===&lt;br /&gt;
You need a process’s pid (ps) to kill it.&lt;br /&gt;
Let suppose you want to kill program ‘apache2‘ that might not be responding. Run ‘ps -A‘ along with grep command.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i apache2&lt;br /&gt;
1285 ?        00:00:00 apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Find process ‘apache2‘, note its pid and kill it. For example, in that case ‘apache2‘ pid is ‘1285‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# kill 1285 (to kill the process apache2)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Every time you re-run a process or start a system, a new pid is generated for each process and you can know about the current running processes and its pid using command ‘ps‘.&lt;br /&gt;
Another way to kill the same process is.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# pkill apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Kill requires job id / process id for sending signals, where as in pkill, you have an option of using pattern, specifying process owner, etc.&lt;br /&gt;
&lt;br /&gt;
===Command: whereis===&lt;br /&gt;
===Command: service===&lt;br /&gt;
===Command: alias===&lt;br /&gt;
===Command: df===&lt;br /&gt;
===Command: du===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Login Script==&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo su student2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if u run:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash --login&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if you login to a machine via ssh e.g:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@machine&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll be invoking ~/.profile Note that ~/.profile (or if not there, one of ~/.bash_profile or ~/.bash_login) normally contains relevant commands to run another script called ~/.bashrc (if said file exists):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if [ -f ~/.bashrc ]; then&lt;br /&gt;
    . ~/.bashrc&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121287</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121287"/>
		<updated>2017-05-07T15:05:00Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Command: kill */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
It is a powerful shell, and features, among other things:&lt;br /&gt;
&lt;br /&gt;
**Command line editing&lt;br /&gt;
**Command history&lt;br /&gt;
**A directory stack (pushd, popd)&lt;br /&gt;
**Command substitution&lt;br /&gt;
**Special variables, like $PPID&lt;br /&gt;
**Autocompletion&lt;br /&gt;
**In-process integer arithmetic: $((...))&lt;br /&gt;
**In-process regexes&lt;br /&gt;
**Aliases&lt;br /&gt;
**Functions&lt;br /&gt;
**Arrays&lt;br /&gt;
**Expansions: tilde, brace, variable&lt;br /&gt;
**Substring awesomeness&lt;br /&gt;
**Conditional expressions&lt;br /&gt;
**Security (restricted shell mode)&lt;br /&gt;
**Job Control&lt;br /&gt;
**Timing&lt;br /&gt;
**Prompt customization&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Using Bash for administrating=&lt;br /&gt;
===Command: find===&lt;br /&gt;
Search for files in the given directory, hierarchically starting at the parent directory and moving to sub-directories.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# find -name *.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: grep===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep user /etc/passwd &lt;br /&gt;
user:x:1000:1000:user,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Ignore word case and all other combination with ‘-i‘ option.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -i USER /etc/passwd &lt;br /&gt;
user:x:1000:1000:User,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Search recursively (-r) i.e. read all files under each directory for a string “127.0.0.1“.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -r &amp;quot;127.0.0.1&amp;quot; /etc/ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: man===&lt;br /&gt;
The ‘man‘ is the system’s manual pager. Man provides online documentation for all the possible options with a command and its usages. Almost all the command comes with their corresponding manual pages. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# man bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Manual page for man page itself, similarly ‘man cat‘ (Manual page for cat command) and ‘man ls‘ (Manual page for command ls).&lt;br /&gt;
&lt;br /&gt;
===Command: ps===&lt;br /&gt;
ps (Process) gives the status of running processes with a unique Id called PID.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
To list status of all the processes along with process id and PID, use option ‘-A‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: This command is very useful when you want to know which processes are running or may need PID sometimes, for process to be killed. You can use it with ‘grep‘ command to find customised output. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i ssh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Here ‘ps‘ is pipelined with ‘grep‘ command to find customised and relevant output of our need.&lt;br /&gt;
&lt;br /&gt;
===Command: kill===&lt;br /&gt;
You need a process’s pid (ps) to kill it.&lt;br /&gt;
Let suppose you want to kill program ‘apache2‘ that might not be responding. Run ‘ps -A‘ along with grep command.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i apache2&lt;br /&gt;
1285 ?        00:00:00 apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Find process ‘apache2‘, note its pid and kill it. For example, in my case ‘apache2‘ pid is ‘1285‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# kill 1285 (to kill the process apache2)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Every time you re-run a process or start a system, a new pid is generated for each process and you can know about the current running processes and its pid using command ‘ps‘.&lt;br /&gt;
Another way to kill the same process is.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# pkill apache2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: Kill requires job id / process id for sending signals, where as in pkill, you have an option of using pattern, specifying process owner, etc.&lt;br /&gt;
&lt;br /&gt;
===Command: whereis===&lt;br /&gt;
===Command: service===&lt;br /&gt;
===Command: alias===&lt;br /&gt;
===Command: df===&lt;br /&gt;
===Command: du===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Login Script==&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo su student2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if u run:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash --login&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if you login to a machine via ssh e.g:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@machine&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll be invoking ~/.profile Note that ~/.profile (or if not there, one of ~/.bash_profile or ~/.bash_login) normally contains relevant commands to run another script called ~/.bashrc (if said file exists):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if [ -f ~/.bashrc ]; then&lt;br /&gt;
    . ~/.bashrc&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121286</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121286"/>
		<updated>2017-05-07T15:02:34Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Command: ps */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
It is a powerful shell, and features, among other things:&lt;br /&gt;
&lt;br /&gt;
**Command line editing&lt;br /&gt;
**Command history&lt;br /&gt;
**A directory stack (pushd, popd)&lt;br /&gt;
**Command substitution&lt;br /&gt;
**Special variables, like $PPID&lt;br /&gt;
**Autocompletion&lt;br /&gt;
**In-process integer arithmetic: $((...))&lt;br /&gt;
**In-process regexes&lt;br /&gt;
**Aliases&lt;br /&gt;
**Functions&lt;br /&gt;
**Arrays&lt;br /&gt;
**Expansions: tilde, brace, variable&lt;br /&gt;
**Substring awesomeness&lt;br /&gt;
**Conditional expressions&lt;br /&gt;
**Security (restricted shell mode)&lt;br /&gt;
**Job Control&lt;br /&gt;
**Timing&lt;br /&gt;
**Prompt customization&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Using Bash for administrating=&lt;br /&gt;
===Command: find===&lt;br /&gt;
Search for files in the given directory, hierarchically starting at the parent directory and moving to sub-directories.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# find -name *.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: grep===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep user /etc/passwd &lt;br /&gt;
user:x:1000:1000:user,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Ignore word case and all other combination with ‘-i‘ option.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -i USER /etc/passwd &lt;br /&gt;
user:x:1000:1000:User,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Search recursively (-r) i.e. read all files under each directory for a string “127.0.0.1“.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -r &amp;quot;127.0.0.1&amp;quot; /etc/ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: man===&lt;br /&gt;
The ‘man‘ is the system’s manual pager. Man provides online documentation for all the possible options with a command and its usages. Almost all the command comes with their corresponding manual pages. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# man bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Manual page for man page itself, similarly ‘man cat‘ (Manual page for cat command) and ‘man ls‘ (Manual page for command ls).&lt;br /&gt;
&lt;br /&gt;
===Command: ps===&lt;br /&gt;
ps (Process) gives the status of running processes with a unique Id called PID.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
To list status of all the processes along with process id and PID, use option ‘-A‘.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: This command is very useful when you want to know which processes are running or may need PID sometimes, for process to be killed. You can use it with ‘grep‘ command to find customised output. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# ps -A | grep -i ssh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Here ‘ps‘ is pipelined with ‘grep‘ command to find customised and relevant output of our need.&lt;br /&gt;
&lt;br /&gt;
===Command: kill===&lt;br /&gt;
===Command: whereis===&lt;br /&gt;
===Command: service===&lt;br /&gt;
===Command: alias===&lt;br /&gt;
===Command: df===&lt;br /&gt;
===Command: du===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Login Script==&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo su student2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if u run:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash --login&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if you login to a machine via ssh e.g:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@machine&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll be invoking ~/.profile Note that ~/.profile (or if not there, one of ~/.bash_profile or ~/.bash_login) normally contains relevant commands to run another script called ~/.bashrc (if said file exists):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if [ -f ~/.bashrc ]; then&lt;br /&gt;
    . ~/.bashrc&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121284</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121284"/>
		<updated>2017-05-07T15:00:35Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Using Bash for administrating */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
It is a powerful shell, and features, among other things:&lt;br /&gt;
&lt;br /&gt;
**Command line editing&lt;br /&gt;
**Command history&lt;br /&gt;
**A directory stack (pushd, popd)&lt;br /&gt;
**Command substitution&lt;br /&gt;
**Special variables, like $PPID&lt;br /&gt;
**Autocompletion&lt;br /&gt;
**In-process integer arithmetic: $((...))&lt;br /&gt;
**In-process regexes&lt;br /&gt;
**Aliases&lt;br /&gt;
**Functions&lt;br /&gt;
**Arrays&lt;br /&gt;
**Expansions: tilde, brace, variable&lt;br /&gt;
**Substring awesomeness&lt;br /&gt;
**Conditional expressions&lt;br /&gt;
**Security (restricted shell mode)&lt;br /&gt;
**Job Control&lt;br /&gt;
**Timing&lt;br /&gt;
**Prompt customization&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Using Bash for administrating=&lt;br /&gt;
===Command: find===&lt;br /&gt;
Search for files in the given directory, hierarchically starting at the parent directory and moving to sub-directories.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# find -name *.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: grep===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep user /etc/passwd &lt;br /&gt;
user:x:1000:1000:user,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Ignore word case and all other combination with ‘-i‘ option.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -i USER /etc/passwd &lt;br /&gt;
user:x:1000:1000:User,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Search recursively (-r) i.e. read all files under each directory for a string “127.0.0.1“.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -r &amp;quot;127.0.0.1&amp;quot; /etc/ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: man===&lt;br /&gt;
The ‘man‘ is the system’s manual pager. Man provides online documentation for all the possible options with a command and its usages. Almost all the command comes with their corresponding manual pages. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# man bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Manual page for man page itself, similarly ‘man cat‘ (Manual page for cat command) and ‘man ls‘ (Manual page for command ls).&lt;br /&gt;
&lt;br /&gt;
===Command: ps===&lt;br /&gt;
===Command: kill===&lt;br /&gt;
===Command: whereis===&lt;br /&gt;
===Command: service===&lt;br /&gt;
===Command: alias===&lt;br /&gt;
===Command: df===&lt;br /&gt;
===Command: du===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Login Script==&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo su student2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if u run:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash --login&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if you login to a machine via ssh e.g:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@machine&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll be invoking ~/.profile Note that ~/.profile (or if not there, one of ~/.bash_profile or ~/.bash_login) normally contains relevant commands to run another script called ~/.bashrc (if said file exists):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if [ -f ~/.bashrc ]; then&lt;br /&gt;
    . ~/.bashrc&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121281</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121281"/>
		<updated>2017-05-07T14:56:34Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Command: man */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
It is a powerful shell, and features, among other things:&lt;br /&gt;
&lt;br /&gt;
**Command line editing&lt;br /&gt;
**Command history&lt;br /&gt;
**A directory stack (pushd, popd)&lt;br /&gt;
**Command substitution&lt;br /&gt;
**Special variables, like $PPID&lt;br /&gt;
**Autocompletion&lt;br /&gt;
**In-process integer arithmetic: $((...))&lt;br /&gt;
**In-process regexes&lt;br /&gt;
**Aliases&lt;br /&gt;
**Functions&lt;br /&gt;
**Arrays&lt;br /&gt;
**Expansions: tilde, brace, variable&lt;br /&gt;
**Substring awesomeness&lt;br /&gt;
**Conditional expressions&lt;br /&gt;
**Security (restricted shell mode)&lt;br /&gt;
**Job Control&lt;br /&gt;
**Timing&lt;br /&gt;
**Prompt customization&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Using Bash for administrating=&lt;br /&gt;
===Command: find===&lt;br /&gt;
Search for files in the given directory, hierarchically starting at the parent directory and moving to sub-directories.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# find -name *.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: grep===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep user /etc/passwd &lt;br /&gt;
user:x:1000:1000:user,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Ignore word case and all other combination with ‘-i‘ option.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -i USER /etc/passwd &lt;br /&gt;
user:x:1000:1000:User,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Search recursively (-r) i.e. read all files under each directory for a string “127.0.0.1“.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -r &amp;quot;127.0.0.1&amp;quot; /etc/ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: man===&lt;br /&gt;
The ‘man‘ is the system’s manual pager. Man provides online documentation for all the possible options with a command and its usages. Almost all the command comes with their corresponding manual pages. For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# man bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Manual page for man page itself, similarly ‘man cat‘ (Manual page for cat command) and ‘man ls‘ (Manual page for command ls).&lt;br /&gt;
&lt;br /&gt;
==Login Script==&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo su student2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if u run:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash --login&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if you login to a machine via ssh e.g:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@machine&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll be invoking ~/.profile Note that ~/.profile (or if not there, one of ~/.bash_profile or ~/.bash_login) normally contains relevant commands to run another script called ~/.bashrc (if said file exists):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if [ -f ~/.bashrc ]; then&lt;br /&gt;
    . ~/.bashrc&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121276</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121276"/>
		<updated>2017-05-07T14:55:09Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Using Bash for administrating */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
It is a powerful shell, and features, among other things:&lt;br /&gt;
&lt;br /&gt;
**Command line editing&lt;br /&gt;
**Command history&lt;br /&gt;
**A directory stack (pushd, popd)&lt;br /&gt;
**Command substitution&lt;br /&gt;
**Special variables, like $PPID&lt;br /&gt;
**Autocompletion&lt;br /&gt;
**In-process integer arithmetic: $((...))&lt;br /&gt;
**In-process regexes&lt;br /&gt;
**Aliases&lt;br /&gt;
**Functions&lt;br /&gt;
**Arrays&lt;br /&gt;
**Expansions: tilde, brace, variable&lt;br /&gt;
**Substring awesomeness&lt;br /&gt;
**Conditional expressions&lt;br /&gt;
**Security (restricted shell mode)&lt;br /&gt;
**Job Control&lt;br /&gt;
**Timing&lt;br /&gt;
**Prompt customization&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Using Bash for administrating=&lt;br /&gt;
===Command: find===&lt;br /&gt;
Search for files in the given directory, hierarchically starting at the parent directory and moving to sub-directories.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# find -name *.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: grep===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep user /etc/passwd &lt;br /&gt;
user:x:1000:1000:user,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Ignore word case and all other combination with ‘-i‘ option.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -i USER /etc/passwd &lt;br /&gt;
user:x:1000:1000:User,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Search recursively (-r) i.e. read all files under each directory for a string “127.0.0.1“.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -r &amp;quot;127.0.0.1&amp;quot; /etc/ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: man===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Login Script==&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo su student2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if u run:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash --login&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if you login to a machine via ssh e.g:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@machine&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll be invoking ~/.profile Note that ~/.profile (or if not there, one of ~/.bash_profile or ~/.bash_login) normally contains relevant commands to run another script called ~/.bashrc (if said file exists):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if [ -f ~/.bashrc ]; then&lt;br /&gt;
    . ~/.bashrc&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121274</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121274"/>
		<updated>2017-05-07T14:54:25Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Command: grep */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
It is a powerful shell, and features, among other things:&lt;br /&gt;
&lt;br /&gt;
**Command line editing&lt;br /&gt;
**Command history&lt;br /&gt;
**A directory stack (pushd, popd)&lt;br /&gt;
**Command substitution&lt;br /&gt;
**Special variables, like $PPID&lt;br /&gt;
**Autocompletion&lt;br /&gt;
**In-process integer arithmetic: $((...))&lt;br /&gt;
**In-process regexes&lt;br /&gt;
**Aliases&lt;br /&gt;
**Functions&lt;br /&gt;
**Arrays&lt;br /&gt;
**Expansions: tilde, brace, variable&lt;br /&gt;
**Substring awesomeness&lt;br /&gt;
**Conditional expressions&lt;br /&gt;
**Security (restricted shell mode)&lt;br /&gt;
**Job Control&lt;br /&gt;
**Timing&lt;br /&gt;
**Prompt customization&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Using Bash for administrating=&lt;br /&gt;
===Command: find===&lt;br /&gt;
Search for files in the given directory, hierarchically starting at the parent directory and moving to sub-directories.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# find -name *.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: grep===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep user /etc/passwd &lt;br /&gt;
user:x:1000:1000:user,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Ignore word case and all other combination with ‘-i‘ option.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -i USER /etc/passwd &lt;br /&gt;
user:x:1000:1000:User,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Search recursively (-r) i.e. read all files under each directory for a string “127.0.0.1“.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -r &amp;quot;127.0.0.1&amp;quot; /etc/ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Login Script==&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo su student2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if u run:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash --login&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if you login to a machine via ssh e.g:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@machine&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll be invoking ~/.profile Note that ~/.profile (or if not there, one of ~/.bash_profile or ~/.bash_login) normally contains relevant commands to run another script called ~/.bashrc (if said file exists):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if [ -f ~/.bashrc ]; then&lt;br /&gt;
    . ~/.bashrc&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121273</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121273"/>
		<updated>2017-05-07T14:53:45Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Command: grep */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
It is a powerful shell, and features, among other things:&lt;br /&gt;
&lt;br /&gt;
**Command line editing&lt;br /&gt;
**Command history&lt;br /&gt;
**A directory stack (pushd, popd)&lt;br /&gt;
**Command substitution&lt;br /&gt;
**Special variables, like $PPID&lt;br /&gt;
**Autocompletion&lt;br /&gt;
**In-process integer arithmetic: $((...))&lt;br /&gt;
**In-process regexes&lt;br /&gt;
**Aliases&lt;br /&gt;
**Functions&lt;br /&gt;
**Arrays&lt;br /&gt;
**Expansions: tilde, brace, variable&lt;br /&gt;
**Substring awesomeness&lt;br /&gt;
**Conditional expressions&lt;br /&gt;
**Security (restricted shell mode)&lt;br /&gt;
**Job Control&lt;br /&gt;
**Timing&lt;br /&gt;
**Prompt customization&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Using Bash for administrating=&lt;br /&gt;
===Command: find===&lt;br /&gt;
Search for files in the given directory, hierarchically starting at the parent directory and moving to sub-directories.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# find -name *.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: grep===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep user /etc/passwd &lt;br /&gt;
user:x:1000:1000:user,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Ignore word case and all other combination with ‘-i‘ option.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep -i USER /etc/passwd &lt;br /&gt;
user:x:1000:1000:User,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Login Script==&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo su student2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if u run:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash --login&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if you login to a machine via ssh e.g:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@machine&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll be invoking ~/.profile Note that ~/.profile (or if not there, one of ~/.bash_profile or ~/.bash_login) normally contains relevant commands to run another script called ~/.bashrc (if said file exists):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if [ -f ~/.bashrc ]; then&lt;br /&gt;
    . ~/.bashrc&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121271</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121271"/>
		<updated>2017-05-07T14:52:49Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Using Bash for administrating */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
It is a powerful shell, and features, among other things:&lt;br /&gt;
&lt;br /&gt;
**Command line editing&lt;br /&gt;
**Command history&lt;br /&gt;
**A directory stack (pushd, popd)&lt;br /&gt;
**Command substitution&lt;br /&gt;
**Special variables, like $PPID&lt;br /&gt;
**Autocompletion&lt;br /&gt;
**In-process integer arithmetic: $((...))&lt;br /&gt;
**In-process regexes&lt;br /&gt;
**Aliases&lt;br /&gt;
**Functions&lt;br /&gt;
**Arrays&lt;br /&gt;
**Expansions: tilde, brace, variable&lt;br /&gt;
**Substring awesomeness&lt;br /&gt;
**Conditional expressions&lt;br /&gt;
**Security (restricted shell mode)&lt;br /&gt;
**Job Control&lt;br /&gt;
**Timing&lt;br /&gt;
**Prompt customization&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Using Bash for administrating=&lt;br /&gt;
===Command: find===&lt;br /&gt;
Search for files in the given directory, hierarchically starting at the parent directory and moving to sub-directories.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# find -name *.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===Command: grep===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# grep user /etc/passwd &lt;br /&gt;
user:x:1000:1000:user,,,:/home/user:/bin/bash&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Login Script==&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo su student2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if u run:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash --login&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if you login to a machine via ssh e.g:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@machine&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll be invoking ~/.profile Note that ~/.profile (or if not there, one of ~/.bash_profile or ~/.bash_login) normally contains relevant commands to run another script called ~/.bashrc (if said file exists):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if [ -f ~/.bashrc ]; then&lt;br /&gt;
    . ~/.bashrc&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121267</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121267"/>
		<updated>2017-05-07T14:51:10Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Command: find */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
It is a powerful shell, and features, among other things:&lt;br /&gt;
&lt;br /&gt;
**Command line editing&lt;br /&gt;
**Command history&lt;br /&gt;
**A directory stack (pushd, popd)&lt;br /&gt;
**Command substitution&lt;br /&gt;
**Special variables, like $PPID&lt;br /&gt;
**Autocompletion&lt;br /&gt;
**In-process integer arithmetic: $((...))&lt;br /&gt;
**In-process regexes&lt;br /&gt;
**Aliases&lt;br /&gt;
**Functions&lt;br /&gt;
**Arrays&lt;br /&gt;
**Expansions: tilde, brace, variable&lt;br /&gt;
**Substring awesomeness&lt;br /&gt;
**Conditional expressions&lt;br /&gt;
**Security (restricted shell mode)&lt;br /&gt;
**Job Control&lt;br /&gt;
**Timing&lt;br /&gt;
**Prompt customization&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Using Bash for administrating=&lt;br /&gt;
===Command: find===&lt;br /&gt;
Search for files in the given directory, hierarchically starting at the parent directory and moving to sub-directories.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# find -name *.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Login Script==&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo su student2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if u run:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash --login&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if you login to a machine via ssh e.g:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@machine&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll be invoking ~/.profile Note that ~/.profile (or if not there, one of ~/.bash_profile or ~/.bash_login) normally contains relevant commands to run another script called ~/.bashrc (if said file exists):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if [ -f ~/.bashrc ]; then&lt;br /&gt;
    . ~/.bashrc&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121266</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121266"/>
		<updated>2017-05-07T14:50:59Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Using Bash for administrating */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
It is a powerful shell, and features, among other things:&lt;br /&gt;
&lt;br /&gt;
**Command line editing&lt;br /&gt;
**Command history&lt;br /&gt;
**A directory stack (pushd, popd)&lt;br /&gt;
**Command substitution&lt;br /&gt;
**Special variables, like $PPID&lt;br /&gt;
**Autocompletion&lt;br /&gt;
**In-process integer arithmetic: $((...))&lt;br /&gt;
**In-process regexes&lt;br /&gt;
**Aliases&lt;br /&gt;
**Functions&lt;br /&gt;
**Arrays&lt;br /&gt;
**Expansions: tilde, brace, variable&lt;br /&gt;
**Substring awesomeness&lt;br /&gt;
**Conditional expressions&lt;br /&gt;
**Security (restricted shell mode)&lt;br /&gt;
**Job Control&lt;br /&gt;
**Timing&lt;br /&gt;
**Prompt customization&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Using Bash for administrating=&lt;br /&gt;
===Command: find===&lt;br /&gt;
Search for files in the given directory, hierarchically starting at the parent directory and moving to sub-directories.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# find -name *.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@tecmint:~# find -name *.tar.gz &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Login Script==&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo su student2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if u run:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash --login&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if you login to a machine via ssh e.g:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@machine&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll be invoking ~/.profile Note that ~/.profile (or if not there, one of ~/.bash_profile or ~/.bash_login) normally contains relevant commands to run another script called ~/.bashrc (if said file exists):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if [ -f ~/.bashrc ]; then&lt;br /&gt;
    . ~/.bashrc&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121263</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121263"/>
		<updated>2017-05-07T14:50:07Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Command: find */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
It is a powerful shell, and features, among other things:&lt;br /&gt;
&lt;br /&gt;
**Command line editing&lt;br /&gt;
**Command history&lt;br /&gt;
**A directory stack (pushd, popd)&lt;br /&gt;
**Command substitution&lt;br /&gt;
**Special variables, like $PPID&lt;br /&gt;
**Autocompletion&lt;br /&gt;
**In-process integer arithmetic: $((...))&lt;br /&gt;
**In-process regexes&lt;br /&gt;
**Aliases&lt;br /&gt;
**Functions&lt;br /&gt;
**Arrays&lt;br /&gt;
**Expansions: tilde, brace, variable&lt;br /&gt;
**Substring awesomeness&lt;br /&gt;
**Conditional expressions&lt;br /&gt;
**Security (restricted shell mode)&lt;br /&gt;
**Job Control&lt;br /&gt;
**Timing&lt;br /&gt;
**Prompt customization&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Using Bash for administrating=&lt;br /&gt;
===Command: find===&lt;br /&gt;
Search for files in the given directory, hierarchically starting at the parent directory and moving to sub-directories.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# find -name *.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Login Script==&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo su student2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if u run:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash --login&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if you login to a machine via ssh e.g:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@machine&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll be invoking ~/.profile Note that ~/.profile (or if not there, one of ~/.bash_profile or ~/.bash_login) normally contains relevant commands to run another script called ~/.bashrc (if said file exists):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if [ -f ~/.bashrc ]; then&lt;br /&gt;
    . ~/.bashrc&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121262</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121262"/>
		<updated>2017-05-07T14:49:48Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Command: find */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
It is a powerful shell, and features, among other things:&lt;br /&gt;
&lt;br /&gt;
**Command line editing&lt;br /&gt;
**Command history&lt;br /&gt;
**A directory stack (pushd, popd)&lt;br /&gt;
**Command substitution&lt;br /&gt;
**Special variables, like $PPID&lt;br /&gt;
**Autocompletion&lt;br /&gt;
**In-process integer arithmetic: $((...))&lt;br /&gt;
**In-process regexes&lt;br /&gt;
**Aliases&lt;br /&gt;
**Functions&lt;br /&gt;
**Arrays&lt;br /&gt;
**Expansions: tilde, brace, variable&lt;br /&gt;
**Substring awesomeness&lt;br /&gt;
**Conditional expressions&lt;br /&gt;
**Security (restricted shell mode)&lt;br /&gt;
**Job Control&lt;br /&gt;
**Timing&lt;br /&gt;
**Prompt customization&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Using Bash for administrating=&lt;br /&gt;
==Command: find==&lt;br /&gt;
Search for files in the given directory, hierarchically starting at the parent directory and moving to sub-directories.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@user:~# find -name *.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Login Script==&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo su student2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if u run:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash --login&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if you login to a machine via ssh e.g:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@machine&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll be invoking ~/.profile Note that ~/.profile (or if not there, one of ~/.bash_profile or ~/.bash_login) normally contains relevant commands to run another script called ~/.bashrc (if said file exists):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if [ -f ~/.bashrc ]; then&lt;br /&gt;
    . ~/.bashrc&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121261</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121261"/>
		<updated>2017-05-07T14:49:36Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Command: find */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
It is a powerful shell, and features, among other things:&lt;br /&gt;
&lt;br /&gt;
**Command line editing&lt;br /&gt;
**Command history&lt;br /&gt;
**A directory stack (pushd, popd)&lt;br /&gt;
**Command substitution&lt;br /&gt;
**Special variables, like $PPID&lt;br /&gt;
**Autocompletion&lt;br /&gt;
**In-process integer arithmetic: $((...))&lt;br /&gt;
**In-process regexes&lt;br /&gt;
**Aliases&lt;br /&gt;
**Functions&lt;br /&gt;
**Arrays&lt;br /&gt;
**Expansions: tilde, brace, variable&lt;br /&gt;
**Substring awesomeness&lt;br /&gt;
**Conditional expressions&lt;br /&gt;
**Security (restricted shell mode)&lt;br /&gt;
**Job Control&lt;br /&gt;
**Timing&lt;br /&gt;
**Prompt customization&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Using Bash for administrating=&lt;br /&gt;
==Command: find==&lt;br /&gt;
Search for files in the given directory, hierarchically starting at the parent directory and moving to sub-directories.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@steven:~# find -name *.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Login Script==&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo su student2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if u run:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash --login&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if you login to a machine via ssh e.g:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@machine&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll be invoking ~/.profile Note that ~/.profile (or if not there, one of ~/.bash_profile or ~/.bash_login) normally contains relevant commands to run another script called ~/.bashrc (if said file exists):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if [ -f ~/.bashrc ]; then&lt;br /&gt;
    . ~/.bashrc&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121259</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121259"/>
		<updated>2017-05-07T14:49:16Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Command: find */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
It is a powerful shell, and features, among other things:&lt;br /&gt;
&lt;br /&gt;
**Command line editing&lt;br /&gt;
**Command history&lt;br /&gt;
**A directory stack (pushd, popd)&lt;br /&gt;
**Command substitution&lt;br /&gt;
**Special variables, like $PPID&lt;br /&gt;
**Autocompletion&lt;br /&gt;
**In-process integer arithmetic: $((...))&lt;br /&gt;
**In-process regexes&lt;br /&gt;
**Aliases&lt;br /&gt;
**Functions&lt;br /&gt;
**Arrays&lt;br /&gt;
**Expansions: tilde, brace, variable&lt;br /&gt;
**Substring awesomeness&lt;br /&gt;
**Conditional expressions&lt;br /&gt;
**Security (restricted shell mode)&lt;br /&gt;
**Job Control&lt;br /&gt;
**Timing&lt;br /&gt;
**Prompt customization&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Using Bash for administrating=&lt;br /&gt;
==Command: find==&lt;br /&gt;
Search for files in the given directory, hierarchically starting at the parent directory and moving to sub-directories.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@tecmint:~# find -name *.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Login Script==&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo su student2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if u run:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash --login&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if you login to a machine via ssh e.g:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@machine&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll be invoking ~/.profile Note that ~/.profile (or if not there, one of ~/.bash_profile or ~/.bash_login) normally contains relevant commands to run another script called ~/.bashrc (if said file exists):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if [ -f ~/.bashrc ]; then&lt;br /&gt;
    . ~/.bashrc&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121258</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121258"/>
		<updated>2017-05-07T14:48:27Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Using Bash for administrating */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
It is a powerful shell, and features, among other things:&lt;br /&gt;
&lt;br /&gt;
**Command line editing&lt;br /&gt;
**Command history&lt;br /&gt;
**A directory stack (pushd, popd)&lt;br /&gt;
**Command substitution&lt;br /&gt;
**Special variables, like $PPID&lt;br /&gt;
**Autocompletion&lt;br /&gt;
**In-process integer arithmetic: $((...))&lt;br /&gt;
**In-process regexes&lt;br /&gt;
**Aliases&lt;br /&gt;
**Functions&lt;br /&gt;
**Arrays&lt;br /&gt;
**Expansions: tilde, brace, variable&lt;br /&gt;
**Substring awesomeness&lt;br /&gt;
**Conditional expressions&lt;br /&gt;
**Security (restricted shell mode)&lt;br /&gt;
**Job Control&lt;br /&gt;
**Timing&lt;br /&gt;
**Prompt customization&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Using Bash for administrating=&lt;br /&gt;
==Command: find==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Login Script==&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo su student2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if u run:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash --login&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if you login to a machine via ssh e.g:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@machine&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll be invoking ~/.profile Note that ~/.profile (or if not there, one of ~/.bash_profile or ~/.bash_login) normally contains relevant commands to run another script called ~/.bashrc (if said file exists):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if [ -f ~/.bashrc ]; then&lt;br /&gt;
    . ~/.bashrc&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121257</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121257"/>
		<updated>2017-05-07T14:48:18Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Using Bash for administrating */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
It is a powerful shell, and features, among other things:&lt;br /&gt;
&lt;br /&gt;
**Command line editing&lt;br /&gt;
**Command history&lt;br /&gt;
**A directory stack (pushd, popd)&lt;br /&gt;
**Command substitution&lt;br /&gt;
**Special variables, like $PPID&lt;br /&gt;
**Autocompletion&lt;br /&gt;
**In-process integer arithmetic: $((...))&lt;br /&gt;
**In-process regexes&lt;br /&gt;
**Aliases&lt;br /&gt;
**Functions&lt;br /&gt;
**Arrays&lt;br /&gt;
**Expansions: tilde, brace, variable&lt;br /&gt;
**Substring awesomeness&lt;br /&gt;
**Conditional expressions&lt;br /&gt;
**Security (restricted shell mode)&lt;br /&gt;
**Job Control&lt;br /&gt;
**Timing&lt;br /&gt;
**Prompt customization&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Using Bash for administrating=&lt;br /&gt;
==Command: find==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Login Script==&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo su student2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if u run:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash --login&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if you login to a machine via ssh e.g:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@machine&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll be invoking ~/.profile Note that ~/.profile (or if not there, one of ~/.bash_profile or ~/.bash_login) normally contains relevant commands to run another script called ~/.bashrc (if said file exists):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if [ -f ~/.bashrc ]; then&lt;br /&gt;
    . ~/.bashrc&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121256</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121256"/>
		<updated>2017-05-07T14:46:28Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Bash Configuration */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
It is a powerful shell, and features, among other things:&lt;br /&gt;
&lt;br /&gt;
**Command line editing&lt;br /&gt;
**Command history&lt;br /&gt;
**A directory stack (pushd, popd)&lt;br /&gt;
**Command substitution&lt;br /&gt;
**Special variables, like $PPID&lt;br /&gt;
**Autocompletion&lt;br /&gt;
**In-process integer arithmetic: $((...))&lt;br /&gt;
**In-process regexes&lt;br /&gt;
**Aliases&lt;br /&gt;
**Functions&lt;br /&gt;
**Arrays&lt;br /&gt;
**Expansions: tilde, brace, variable&lt;br /&gt;
**Substring awesomeness&lt;br /&gt;
**Conditional expressions&lt;br /&gt;
**Security (restricted shell mode)&lt;br /&gt;
**Job Control&lt;br /&gt;
**Timing&lt;br /&gt;
**Prompt customization&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Using Bash for administrating=&lt;br /&gt;
==Login Script==&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo su student2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if u run:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash --login&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if you login to a machine via ssh e.g:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@machine&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll be invoking ~/.profile Note that ~/.profile (or if not there, one of ~/.bash_profile or ~/.bash_login) normally contains relevant commands to run another script called ~/.bashrc (if said file exists):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if [ -f ~/.bashrc ]; then&lt;br /&gt;
    . ~/.bashrc&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121250</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121250"/>
		<updated>2017-05-07T14:18:57Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Short introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
It is a powerful shell, and features, among other things:&lt;br /&gt;
&lt;br /&gt;
**Command line editing&lt;br /&gt;
**Command history&lt;br /&gt;
**A directory stack (pushd, popd)&lt;br /&gt;
**Command substitution&lt;br /&gt;
**Special variables, like $PPID&lt;br /&gt;
**Autocompletion&lt;br /&gt;
**In-process integer arithmetic: $((...))&lt;br /&gt;
**In-process regexes&lt;br /&gt;
**Aliases&lt;br /&gt;
**Functions&lt;br /&gt;
**Arrays&lt;br /&gt;
**Expansions: tilde, brace, variable&lt;br /&gt;
**Substring awesomeness&lt;br /&gt;
**Conditional expressions&lt;br /&gt;
**Security (restricted shell mode)&lt;br /&gt;
**Job Control&lt;br /&gt;
**Timing&lt;br /&gt;
**Prompt customization&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Bash Configuration=&lt;br /&gt;
==Login Script==&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo su student2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if u run:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash --login&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if you login to a machine via ssh e.g:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@machine&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll be invoking ~/.profile Note that ~/.profile (or if not there, one of ~/.bash_profile or ~/.bash_login) normally contains relevant commands to run another script called ~/.bashrc (if said file exists):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if [ -f ~/.bashrc ]; then&lt;br /&gt;
    . ~/.bashrc&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121229</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121229"/>
		<updated>2017-05-07T11:29:59Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Login Script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Bash Configuration=&lt;br /&gt;
==Login Script==&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo su student2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if u run:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash --login&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or if you login to a machine via ssh e.g:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@machine&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll be invoking ~/.profile Note that ~/.profile (or if not there, one of ~/.bash_profile or ~/.bash_login) normally contains relevant commands to run another script called ~/.bashrc (if said file exists):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if [ -f ~/.bashrc ]; then&lt;br /&gt;
    . ~/.bashrc&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121226</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121226"/>
		<updated>2017-05-07T11:20:34Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Login Script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Bash Configuration=&lt;br /&gt;
==Login Script==&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
{|style=&amp;quot;background:lightyellow;width:500px;margin:3px;border:1px solid lightgrey&amp;quot; align=centre&lt;br /&gt;
| style=&amp;quot;padding:0px 0px 0px 80px;font-family:courier;font-size:8pt;&amp;quot; | sudo su student2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121225</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121225"/>
		<updated>2017-05-07T11:19:52Z</updated>

		<summary type="html">&lt;p&gt;Srugam: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Bash Configuration=&lt;br /&gt;
==Login Script==&lt;br /&gt;
When bash is invoked, it runs /etc/profile if that file exists. Next, it looks for these files (in this order) ~/.bash_profile, ~/.bash_login , and ~/.profile.&lt;br /&gt;
The first one that is found gets executed (any others are ignored). In the case of Ubuntu, ~/.profile is found and executed. (All of ~/.bash_profile, ~/.bash_login , and ~/.profile are ignored if --noprofile is used as an option to the underlying bash call). &lt;br /&gt;
So for example, if you login via a virtual console, or if you change to another user e.g:&lt;br /&gt;
&lt;br /&gt;
{|style=&amp;quot;background:lightyellow;width:500px;margin:3px;border:1px solid lightgrey&amp;quot; align=centre&lt;br /&gt;
| style=&amp;quot;padding:0px 0px 0px 80px;font-family:courier;font-size:8pt;&amp;quot; |touch textfile.txt &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121224</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=121224"/>
		<updated>2017-05-07T11:12:50Z</updated>

		<summary type="html">&lt;p&gt;Srugam: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
=Bash Configuration=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=120977</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=120977"/>
		<updated>2017-05-04T19:09:56Z</updated>

		<summary type="html">&lt;p&gt;Srugam: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=120955</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=120955"/>
		<updated>2017-05-04T08:55:48Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Prerequisites/Assumptions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass self-test.&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
[[Category: Script languages]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=120952</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=120952"/>
		<updated>2017-05-04T07:56:04Z</updated>

		<summary type="html">&lt;p&gt;Srugam: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
==Author==&lt;br /&gt;
Translated from Estonian by Steven Rugam&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass&lt;br /&gt;
&lt;br /&gt;
[http://www.example.com SELF TEST FILE]&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
[[Category: Script languages]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=OSadmin_wiki_article&amp;diff=120951</id>
		<title>OSadmin wiki article</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=OSadmin_wiki_article&amp;diff=120951"/>
		<updated>2017-05-04T07:53:12Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Chosen topics */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Intro=&lt;br /&gt;
*Choose a topic from personal experience related with the subject or from topics found on the wiki page&lt;br /&gt;
*[[#Chosen_topics|Write the topic here]].&lt;br /&gt;
*Lecturer will confirm the topic&lt;br /&gt;
*Write your article in wiki environment &lt;br /&gt;
*Inform the [[Operating_systems#Lecturer|lecturer]] when the article is finished&lt;br /&gt;
*Receive feedback for corrections&lt;br /&gt;
&lt;br /&gt;
=Requirements for the wiki article=&lt;br /&gt;
Author: name, group and date when the article is written&lt;br /&gt;
&lt;br /&gt;
==Introduction ==&lt;br /&gt;
Covers points what will be discussed in the article, what are the requirements for the article reader; what are the operating system’s requirements. &lt;br /&gt;
&lt;br /&gt;
==Contents==&lt;br /&gt;
All commands should be easily separable from the overall text. &lt;br /&gt;
Users should be able to copy the commands directly (additional info like prompt and user distinction symbols should be left out from the command description area)&lt;br /&gt;
The text should determine what user permissions are needed to perform these tasks. &lt;br /&gt;
The reader of your article is your fellow students, so try to avoid irrelevant information and stay on topic (don’t explain the meaning of IP address or how to install Ubuntu, when your topic is actually about htop)&lt;br /&gt;
All the content should be referenced. &lt;br /&gt;
Do not use slang and try to be grammatically correct.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:#FF0000&amp;quot;&amp;gt; &lt;br /&gt;
Bear in mind that this is an open environment, so everything you write in your wiki article, will be public. &amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Referencing==&lt;br /&gt;
Best practises of wiki referencing should be used. &lt;br /&gt;
Terms are but between square brackets to reference other articles in the system.&lt;br /&gt;
All drawing and images have to be referenced below the picture and in the text. (for example “System architecture can be viewed on image x, y and z.”)&lt;br /&gt;
Author’s own ideas have to be clearly presentable. Everything used from the sources have to be referenced. &lt;br /&gt;
&lt;br /&gt;
==Fellow student review==&lt;br /&gt;
Please find a fellow student who will review your article and give a feedback on the discussion tab of the article using [http://enos.itcollege.ee/~edmund/materials/viki-artikkel/Assessment-model-for-the-wiki-article.html the following assessment model].&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
Besides a short overview, what was discussed in this article, it should also include the author&#039;s own opinion about the topic. &lt;br /&gt;
&lt;br /&gt;
==Category==&lt;br /&gt;
Add the following category to the end of the article (last row):&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;nowiki&amp;gt;[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=Chosen topics=&lt;br /&gt;
Please write here your topic and name, group:&lt;br /&gt;
* &#039;&#039;&#039;Fedora OS&#039;&#039;&#039;; Anamul Hoque Shihab; CSE-11&lt;br /&gt;
* &#039;&#039;&#039;Basic Automation with Python&#039;&#039;&#039;; Ardi Vaba; CSE-11&lt;br /&gt;
* &#039;&#039;&#039;SSH Encryption&#039;&#039;&#039;; Frank Korving; CSE-11&lt;br /&gt;
* &#039;&#039;&#039;Translation of OSadmin wiki help page to English [[https://wiki.itcollege.ee/index.php/Osadmin_spikker]]&#039;&#039;&#039;; Peep Kuulme; CSE-11&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Cross-Site_Scripting_(XSS)_attacks &#039;&#039;&#039;Cross-Site Scripting&#039;&#039;&#039;]; Masaki Ihara; CSE-11&lt;br /&gt;
*[https://wiki.itcollege.ee/index.php/Auditd &#039;&#039;&#039;Auditd - Linux system monitoring with audit daemon&#039;&#039;&#039;], Nika Ptskialadze, CSE-11&lt;br /&gt;
* &#039;&#039;&#039;GNU Privacy Guard (GnuPG)&#039;&#039;&#039;; Patricia Bruno Barbosa; CSE-11&lt;br /&gt;
* &#039;&#039;&#039;BackBox OS&#039;&#039;&#039;; Ats Tootsi; CSE-11&lt;br /&gt;
*[https://wiki.itcollege.ee/index.php/Apparmor_and_its_usage &#039;&#039;&#039;Apparmor and its usage&#039;&#039;&#039;], Mikus, CSE-11&lt;br /&gt;
*&#039;&#039;&#039;&#039;Arch Linux&#039;&#039;&#039;&#039;;Farhan Nayeem Islam;CSE-C11&lt;br /&gt;
* &#039;&#039;&#039;&#039;VPN basics&#039;&#039;&#039;&#039;, Christian Cataldo, CSE-C11; [https://wiki.itcollege.ee/index.php/VPN_(English_version)]&lt;br /&gt;
* &#039;&#039;Translation of DDoS Wiki page[[https://wiki.itcollege.ee/index.php/DDoS_Eng]]&#039;&#039;&#039;; Andris Männik; CSE-11&lt;br /&gt;
*&#039;&#039;&#039;Translation of Ps Wiki page[[https://wiki.itcollege.ee/index.php/Ps]]&#039;&#039;&#039;&#039;&#039;; Christopher Carr; CSE-11&lt;br /&gt;
*&#039;&#039;&#039;Translation of Bash_Shell wiki page[[https://wiki.itcollege.ee/index.php/BASH_shell_en]]&#039;&#039;&#039;; Steven Rugam; CSE-11&lt;br /&gt;
*&#039;&#039;&#039;Pass: The Standard Unix Password Manager&#039;&#039;&#039;; Oliver Rahula; CSE-11&lt;br /&gt;
*&#039;&#039;&#039;Rsync&#039;&#039;&#039;; Eriks Ocakovskis; C11&lt;br /&gt;
==Ideas==&lt;br /&gt;
* UNIX CLI password manager https://www.passwordstore.org and its GUI http://qtpass.org/&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Osadmin_referaadi_teemad counterpart article in Estonian]&lt;br /&gt;
* http://manpage.io&lt;br /&gt;
* https://linuxjourney.com/&lt;br /&gt;
* [https://linux.die.net/man/ Linux man-pages]&lt;br /&gt;
* [https://linux.die.net Linux docs]&lt;br /&gt;
* http://www.tecmint.com/60-commands-of-linux-a-guide-from-newbies-to-system-administrator/&lt;br /&gt;
* http://www.tecmint.com/useful-linux-commands-for-system-administrators/&lt;br /&gt;
* http://www.cyberciti.biz/tips/top-linux-monitoring-tools.html&lt;br /&gt;
* http://www.thegeekstuff.com/2010/12/50-unix-linux-sysadmin-tutorials&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=120949</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=120949"/>
		<updated>2017-05-03T23:06:52Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Prerequisites/Assumptions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass&lt;br /&gt;
&lt;br /&gt;
[http://www.example.com SELF TEST FILE]&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
[[Category: Script languages]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=120948</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=120948"/>
		<updated>2017-05-03T23:04:58Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Links */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass&lt;br /&gt;
self-test&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc&lt;br /&gt;
&lt;br /&gt;
[[Category: Script languages]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=120947</id>
		<title>BASH shell en</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=BASH_shell_en&amp;diff=120947"/>
		<updated>2017-05-03T23:02:37Z</updated>

		<summary type="html">&lt;p&gt;Srugam: Created page with &amp;quot;=Using shell scripting to automate Linux maintenance tasks=  ==Short introduction== Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and auto...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using shell scripting to automate Linux maintenance tasks=&lt;br /&gt;
&lt;br /&gt;
==Short introduction==&lt;br /&gt;
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.&lt;br /&gt;
When talking about bash in few words, then the structure of the language and possible usages are being checked.&lt;br /&gt;
At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.&lt;br /&gt;
==Purpose==&lt;br /&gt;
Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.&lt;br /&gt;
==Prerequisites/Assumptions==&lt;br /&gt;
History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.&lt;br /&gt;
&lt;br /&gt;
To test prerequisites, you should pass&lt;br /&gt;
self-test&lt;br /&gt;
&lt;br /&gt;
==Target group==&lt;br /&gt;
Support engineers and system administrators.&lt;br /&gt;
&lt;br /&gt;
==Educational materials for learning BASH shell==&lt;br /&gt;
[http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Bash for the beginners]&lt;br /&gt;
==Additional learning materials==&lt;br /&gt;
https://bash.cyberciti.biz/guide/Main_Page&lt;br /&gt;
&lt;br /&gt;
==Topics==&lt;br /&gt;
&lt;br /&gt;
*Bash in general&lt;br /&gt;
**What is bash and shell&lt;br /&gt;
**Bash script writing&lt;br /&gt;
**Executing bash scripts&lt;br /&gt;
*Bash configuration files&lt;br /&gt;
**.bash_profile: .bash_login ja .profile&lt;br /&gt;
**.bashrc&lt;br /&gt;
**.bash_logout&lt;br /&gt;
**/etc/profile, /etc/profile.d/&lt;br /&gt;
**Bash command history in .bash_history&lt;br /&gt;
*Bash Syntax&lt;br /&gt;
**Commenting&lt;br /&gt;
**Symbols with special meaning(metacharacters, escaping characters, wildcards)&lt;br /&gt;
**Difference between quotation marks and single quotation mark&lt;br /&gt;
**Parameters&lt;br /&gt;
**Catching user input and interactive scripts&lt;br /&gt;
**Exit codes&lt;br /&gt;
**Multiple commands on the same row&lt;br /&gt;
**Piping&lt;br /&gt;
**If sentences (if-else, case)&lt;br /&gt;
**Cycles (for, while, until, select)&lt;br /&gt;
**Control of strings (larger than, larger/smaller than or equal, smaller than)&lt;br /&gt;
**File descriptors (stdin, stdout, stderr)&lt;br /&gt;
**File existance scripts&lt;br /&gt;
**Functions&lt;br /&gt;
**Arithmetic operations, rounding&lt;br /&gt;
**Regular expressions&lt;br /&gt;
**Usage of arrays&lt;br /&gt;
*Basics of bash&lt;br /&gt;
**Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)&lt;br /&gt;
**Processes and executing them (ps, pstree, top, &amp;amp;)&lt;br /&gt;
**Detecting shell script mistakes and fixing them&lt;br /&gt;
&lt;br /&gt;
==Example exercises==&lt;br /&gt;
&lt;br /&gt;
*Calculation exercises&lt;br /&gt;
*String manipulations&lt;br /&gt;
*Exercises with files&lt;br /&gt;
*Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)&lt;br /&gt;
*Stopping processes and restarting processes&lt;br /&gt;
*Adding new domains to DNS servers from the shell&lt;br /&gt;
*Converting file lowercase characters to uppercase characters&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
[http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc]&lt;br /&gt;
&lt;br /&gt;
[[Category: Script languages]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Apparmor_and_its_usage&amp;diff=120921</id>
		<title>Apparmor and its usage</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Apparmor_and_its_usage&amp;diff=120921"/>
		<updated>2017-05-02T15:10:03Z</updated>

		<summary type="html">&lt;p&gt;Srugam: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== AppArmor and its usage ===&lt;br /&gt;
== Whats is AppArmor ==&lt;br /&gt;
[[File:Apparmor_logo.png|right|thumb|Logo]]&lt;br /&gt;
&#039;&#039;&#039;[https://wiki.ubuntu.com/AppArmor AppArmor]&#039;&#039;&#039; is a Linux kernel security module that allows the system administrator to restrict programs&#039; capabilities with per-program profiles. Profiles can allow capabilities like network access, raw socket access, and the permission to read, write, or execute files on matching paths. AppArmor supplements the traditional Unix discretionary access control(DAC) model by providing (mandatory access control) (MAC). It was included in the mainline Linux kernel since version 2.6.36 and its development has been supported by [https://www.canonical.com/ Canonical] since 2009.&lt;br /&gt;
It is available by default on Ubuntu and Suse distributions. AppArmor relies on paths instead of inodes, which are used by another similar security mechanism [https://en.wikipedia.org/wiki/Security-Enhanced_Linux SELinux].&lt;br /&gt;
Apparmor uses rules, which are combined into profiles for every process you want to restrict by it. These profiles can be run in &amp;quot;enforce&amp;quot; or &amp;quot;complain&amp;quot; modes. To generate profile you can run it with AppArmor in profile mode. While enforced profile will disallow any restricted activity, profile ran in complain mode will still allow program to do what was intended, but log this violation in logfile.&lt;br /&gt;
&lt;br /&gt;
== AppArmor features ==&lt;br /&gt;
&lt;br /&gt;
AppArmor can restrict following things&lt;br /&gt;
&lt;br /&gt;
* file access (read, write, link, lock)&lt;br /&gt;
* library loading&lt;br /&gt;
* execution of applications&lt;br /&gt;
* coarse-grained network (protocol, type, domain)&lt;br /&gt;
* capabilities&lt;br /&gt;
* coarse owner checks (task must have the same euid/fsuid as the object being checked) starting with Ubuntu 9.10&lt;br /&gt;
* mount starting with Ubuntu 12.04 LTS&lt;br /&gt;
* unix(7) named sockets starting with Ubuntu 13.10&lt;br /&gt;
* DBus API (path, interface, method) starting with Ubuntu 13.10&lt;br /&gt;
* signal(7) starting with Ubuntu 14.04 LTS&lt;br /&gt;
* ptrace(2) starting with Ubuntu 14.04 LTS&lt;br /&gt;
* unix(7) abstract and anonymous sockets starting with Ubuntu 14.10&lt;br /&gt;
&lt;br /&gt;
== AppArmor commands ==&lt;br /&gt;
=== Check status ===&lt;br /&gt;
  apparmor_status&lt;br /&gt;
or&lt;br /&gt;
  aa-status&lt;br /&gt;
&lt;br /&gt;
=== Load profile ===&lt;br /&gt;
  apparmor_parser -a /etc/apparmor.d/profile.name&lt;br /&gt;
&lt;br /&gt;
=== Replace (reload) singe profile ===&lt;br /&gt;
   apparmor_parser -r /etc/apparmor.d/profile.name&lt;br /&gt;
&lt;br /&gt;
=== Reload all profiles ===&lt;br /&gt;
  systemctl reload apparmor&lt;br /&gt;
&lt;br /&gt;
=== Disable profile ===&lt;br /&gt;
   ln -s /etc/apparmor.d/profile.name /etc/apparmor.d/disable/&lt;br /&gt;
   apparmor_parser -R /etc/apparmor.d/profile.name&lt;br /&gt;
&lt;br /&gt;
=== Enabling disabled profile ===&lt;br /&gt;
  rm /etc/apparmor.d/disable/profile.name&lt;br /&gt;
  apparmor_parser -a /etc/apparmor.d/profile.name&lt;br /&gt;
&lt;br /&gt;
=== Run profile in complain mode ===&lt;br /&gt;
  aa-complain /path/to/program&lt;br /&gt;
&lt;br /&gt;
=== Run profile in enforce mode ===&lt;br /&gt;
  aa-enforce /path/to/program&lt;br /&gt;
&lt;br /&gt;
=== Disabling AppArmor ===&lt;br /&gt;
Open &amp;lt;code&amp;gt;/etc/default/grub&amp;lt;/code&amp;gt; file and change or add this line &amp;lt;code&amp;gt;GRUB_CMDLINE_LINUX_DEFAULT=&amp;quot;apparmor=0&amp;quot;&amp;lt;/code&amp;gt;.&lt;br /&gt;
Then run &amp;lt;code&amp;gt;update-grub2&amp;lt;/code&amp;gt; and restart your PC.&lt;br /&gt;
&lt;br /&gt;
== Permission flags ==&lt;br /&gt;
&lt;br /&gt;
These are permission flags which are used in policy files. With them you can specify which things are allowed and which are denied.&lt;br /&gt;
&lt;br /&gt;
* r    - read&lt;br /&gt;
* w    - write -- conflicts with append&lt;br /&gt;
* a    - append -- conflicts with write&lt;br /&gt;
* ux   - unconfined execute&lt;br /&gt;
* Ux   - unconfined execute -- scrub the environment&lt;br /&gt;
* px   - discrete profile execute&lt;br /&gt;
* Px   - discrete profile execute -- scrub the environment&lt;br /&gt;
* cx   - transition to subprofile on execute&lt;br /&gt;
* Cx   - transition to subprofile on execute -- scrub the environment&lt;br /&gt;
* ix   - inherit execute&lt;br /&gt;
* m    - allow PROT_EXEC with mmap(2) calls&lt;br /&gt;
* l    - link&lt;br /&gt;
* k    - lock&lt;br /&gt;
&lt;br /&gt;
=== Example log record in complain mode ===&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
Apr 27 17:35:30 test kernel: [11443.630597] audit: type=1400 audit(1493303730.576:1168): apparmor=&amp;quot;ALLOWED&amp;quot; operation=&amp;quot;open&amp;quot; profile=&amp;quot;/usr/sbin/proftpd&amp;quot; name=&amp;quot;/etc/protocols&amp;quot; pid=21403 comm=&amp;quot;proftpd&amp;quot; requested_mask=&amp;quot;r&amp;quot; denied_mask=&amp;quot;r&amp;quot; fsuid=0 ouid=0&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
apparmor=&amp;quot;ALLOWED&amp;quot; operation=&amp;quot;open&amp;quot; //allows action&lt;br /&gt;
&lt;br /&gt;
profile=&amp;quot;/usr/sbin/proftpd&amp;quot; //program which is allowed to open&lt;br /&gt;
&lt;br /&gt;
name=&amp;quot;/etc/protocols&amp;quot; // file which will be opened &lt;br /&gt;
&lt;br /&gt;
pid=21403 //process id&lt;br /&gt;
&lt;br /&gt;
comm=&amp;quot;proftpd&amp;quot; // actual command&lt;br /&gt;
&lt;br /&gt;
requested_mask=&amp;quot;r&amp;quot; // requested action read&lt;br /&gt;
&lt;br /&gt;
denied_mask=&amp;quot;r&amp;quot; // action to be denied&lt;br /&gt;
&lt;br /&gt;
fsuid=0 ouid=0 //  file system id and object owner uid&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample profile explained ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Last Modified: Wed Apr 26 21:46:31 2017&lt;br /&gt;
#include &amp;lt;tunables/global&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/usr/sbin/nginx {               // profile &lt;br /&gt;
  #include &amp;lt;abstractions/base&amp;gt;  // includes basic base rules&lt;br /&gt;
&lt;br /&gt;
  capability dac_override,      // can override Discretionary access control&lt;br /&gt;
  network inet stream,          // can create ipv4 socket&lt;br /&gt;
&lt;br /&gt;
  /etc/group r,                 //&lt;br /&gt;
  /etc/nginx/conf.d/ r,         //&lt;br /&gt;
  /etc/nginx/mime.types r,      //&lt;br /&gt;
  /etc/nginx/nginx.conf r,      //   file read allowed&lt;br /&gt;
  /etc/nginx/sites-enabled/ r,  //&lt;br /&gt;
  /etc/nsswitch.conf r,         //&lt;br /&gt;
  /etc/passwd r,                //&lt;br /&gt;
  /etc/ssl/openssl.cnf r,       //&lt;br /&gt;
  /usr/sbin/nginx mr,           //   allows reading and writing files in memory &lt;br /&gt;
  /var/log/nginx/error.log w,   //   write to file allowed&lt;br /&gt;
  /var/www/html/** r,           //   read allowed recursively inside directory&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating new profiles ==&lt;br /&gt;
There are two ways of profiling. First one is called &#039;&#039;Stand-Alone profiling&#039;&#039; and second one is &#039;&#039;Systematic profiling&#039;&#039;. &lt;br /&gt;
* Stand-alone is more fit if you want to create profile for one application, however setbacks are, that you need to keep running the profiling process whole time, while you are creating profile.&lt;br /&gt;
* Systematic profiling is meant for multiple processes, and you can restart server and programs while still profiling.&lt;br /&gt;
&lt;br /&gt;
=== Stand-alone profiling ===&lt;br /&gt;
First you probably need to install additional package by running &amp;lt;code&amp;gt;apt install apparmor-utils&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For example, lets try and profile Vsftpd. After installing it, this command needs to be run first &amp;lt;code&amp;gt;aa-genprof /usr/sbin/vsftpd&amp;lt;/code&amp;gt;. It will stay in monitoring mode. Then in other terminal window restart or start Vsftpd daemon by running &amp;lt;code&amp;gt;systemctl restart vsftpd&amp;lt;/code&amp;gt;. After that just proceed with casual tasks. Connect with local user to FTP, upload, download, create and delete files and directories. Also create file in /tmp. After doing this, switch to first terminal window and push &#039;&#039;&#039;S&#039;&#039;&#039; for &#039;&#039;(S)can system log for AppArmor events&#039;&#039;. Aa-genprof will then asks a couple of questions about actions what vsftpd did and you can either approve or disable them, alone with some more options. For example this rule &amp;lt;code&amp;gt;/home/user1/* r&amp;lt;/code&amp;gt;is  very narrow and ftp will not work properly if your system have more than one user. First profile that was made for vsftpd looked like this&lt;br /&gt;
&amp;lt;pre&amp;gt;  # Last Modified: Wed Apr 26 00:39:00 2017&lt;br /&gt;
  #include &amp;lt;tunables/global&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  /usr/sbin/vsftpd {&lt;br /&gt;
  #include &amp;lt;abstractions/authentication&amp;gt;&lt;br /&gt;
  #include &amp;lt;abstractions/base&amp;gt;&lt;br /&gt;
  #include &amp;lt;abstractions/nameservice&amp;gt;&lt;br /&gt;
  #include &amp;lt;abstractions/lxc/container-base&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  /dev/urandom r,&lt;br /&gt;
  /etc/fstab r,&lt;br /&gt;
  /etc/ftpusers r,&lt;br /&gt;
  /etc/hosts.allow r,&lt;br /&gt;
  /etc/hosts.deny r,&lt;br /&gt;
  /etc/mtab r,&lt;br /&gt;
  /etc/shells r,&lt;br /&gt;
  /etc/vsftpd.* r,&lt;br /&gt;
  /etc/vsftpd/* r,&lt;br /&gt;
  /home/*/ rw,&lt;br /&gt;
  /usr/sbin/vsftpd mrix,&lt;br /&gt;
  /var/log/vsftpd.log w,&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After you test it out, you will notice, that you can still access pretty much everything even when this profile does not specify it. It is because the line &amp;lt;code&amp;gt;#include &amp;lt;abstractions/lxc/container-base&amp;gt;&amp;lt;/code&amp;gt; gives wide access. So instead i changed permissions to be more narrow, and now profile looked like this. User will be able to write in his home directory and in /tmp. He will not see contents in /home.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Last Modified: Wed Apr 26 20:39:27 2017&lt;br /&gt;
#include &amp;lt;tunables/global&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/usr/sbin/vsftpd {&lt;br /&gt;
  #include &amp;lt;abstractions/authentication&amp;gt;&lt;br /&gt;
  #include &amp;lt;abstractions/base&amp;gt;&lt;br /&gt;
  #include &amp;lt;abstractions/nameservice&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  capability audit_write,&lt;br /&gt;
  capability setgid,&lt;br /&gt;
  capability setuid,&lt;br /&gt;
  capability sys_admin,&lt;br /&gt;
  capability sys_chroot,&lt;br /&gt;
&lt;br /&gt;
  / r,&lt;br /&gt;
  /dev/urandom r,&lt;br /&gt;
  /etc/fstab r,&lt;br /&gt;
  /etc/ftpusers r,&lt;br /&gt;
  /etc/hosts.allow r,&lt;br /&gt;
  /etc/hosts.deny r,&lt;br /&gt;
  /etc/mtab r,&lt;br /&gt;
  /etc/shells r,&lt;br /&gt;
  /etc/vsftpd.* r,&lt;br /&gt;
  /etc/vsftpd/* r,&lt;br /&gt;
  /tmp/ r,&lt;br /&gt;
  /tmp/* w,&lt;br /&gt;
  /usr/sbin/vsftpd mrix,&lt;br /&gt;
  /var/log/vsftpd.log w,&lt;br /&gt;
  @{HOME}/ r,&lt;br /&gt;
  @{HOME}/* w,&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Systematic profiling ===&lt;br /&gt;
&lt;br /&gt;
Lets try and do systematic profiling on vsftpd and nginx. After installing them, this command needs to be run in order to create profile skeleton for both programms &amp;lt;code&amp;gt;aa-autodep vsftpd nginx&amp;lt;/code&amp;gt;. After that run this command to puth both profiles in complain mode &amp;lt;code&amp;gt;aa-complain vsftpd nginx&amp;lt;/code&amp;gt;.&lt;br /&gt;
Then restart both services &amp;lt;code&amp;gt;systemctl restart vsftpd ; systemctl restart nginx&amp;lt;/code&amp;gt;&lt;br /&gt;
and do some basic tasks. Open html page in web browser, create and open some subdirectories. Upload and delete files with ftp client. After you think you have done everything you require from both services, run this command &amp;lt;code&amp;gt;aa-logprof&amp;lt;/code&amp;gt; and approve rules. You may need to run it a few times untill you tweak rules just right. Below are the basic rules which allows ftp juser to upload files in his home directory and in /var/www/html/, and ngix to serve them properly over http.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Last Modified: Wed Apr 26 21:50:54 2017&lt;br /&gt;
#include &amp;lt;tunables/global&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/usr/sbin/vsftpd {&lt;br /&gt;
  #include &amp;lt;abstractions/base&amp;gt;&lt;br /&gt;
  #include &amp;lt;abstractions/postfix-common&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  capability audit_write,&lt;br /&gt;
  capability net_bind_service,&lt;br /&gt;
  capability sys_admin,&lt;br /&gt;
&lt;br /&gt;
  network inet6 stream,&lt;br /&gt;
  network netlink raw,&lt;br /&gt;
&lt;br /&gt;
  / r,&lt;br /&gt;
  /etc/ftpusers r,&lt;br /&gt;
  /etc/group r,&lt;br /&gt;
  /etc/login.defs r,&lt;br /&gt;
  /etc/nsswitch.conf r,&lt;br /&gt;
  /etc/pam.d/* r,&lt;br /&gt;
  /etc/passwd r,&lt;br /&gt;
  /etc/securetty r,&lt;br /&gt;
  /etc/shadow r,&lt;br /&gt;
  /etc/shells r,&lt;br /&gt;
  /etc/vsftpd.conf r,&lt;br /&gt;
  @{HOME}/ r,&lt;br /&gt;
  @{HOME}/** rw,&lt;br /&gt;
  /usr/sbin/vsftpd mr,&lt;br /&gt;
  /var/ r,&lt;br /&gt;
  /var/log/vsftpd.log w,&lt;br /&gt;
  /var/www/ rw,&lt;br /&gt;
  /var/www/html/** rw,&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Last Modified: Wed Apr 26 21:46:31 2017&lt;br /&gt;
#include &amp;lt;tunables/global&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/usr/sbin/nginx {&lt;br /&gt;
  #include &amp;lt;abstractions/base&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  capability dac_override,&lt;br /&gt;
&lt;br /&gt;
  network inet stream,&lt;br /&gt;
&lt;br /&gt;
  /etc/group r,&lt;br /&gt;
  /etc/nginx/conf.d/ r,&lt;br /&gt;
  /etc/nginx/mime.types r,&lt;br /&gt;
  /etc/nginx/nginx.conf r,&lt;br /&gt;
  /etc/nginx/sites-enabled/ r,&lt;br /&gt;
  /etc/nsswitch.conf r,&lt;br /&gt;
  /etc/passwd r,&lt;br /&gt;
  /etc/ssl/openssl.cnf r,&lt;br /&gt;
  /usr/sbin/nginx mr,&lt;br /&gt;
  /var/log/nginx/error.log w,&lt;br /&gt;
  /var/www/html/** r,&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Practical example by hardening server ==&lt;br /&gt;
&lt;br /&gt;
Lets assume that you want to set up Ubuntu LTS server and quickly harden it with AppArmor. The server will run Virtualmin as a server control panel.&lt;br /&gt;
First you install Virtualmin by running these commands. Saddly they do not provide checksumms.&lt;br /&gt;
&amp;lt;pre&amp;gt;wget http://software.virtualmin.com/gpl/scripts/install.sh&lt;br /&gt;
bash install.sh&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then install additional profiles&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
apt install apparmor-profiles&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By checking &amp;lt;code&amp;gt;aa-status&amp;lt;/code&amp;gt; you can see that there are bunch of profiles already in enforce and complain mode.&lt;br /&gt;
&lt;br /&gt;
[[File:Aa-status.png|80px]]&lt;br /&gt;
&lt;br /&gt;
Next, to actually enable  profiling on new process, you need to install AppArmor tools &amp;lt;code&amp;gt;apt-get install apparmor-utils&amp;lt;/code&amp;gt;&lt;br /&gt;
Then put proftpd process in complaint mode&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
aa-autodep proftpd&lt;br /&gt;
aa-complain proftpd&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you are running more than one program in complain mode, then by default kernel might limit messages logged, and this might not let you build complete profile. To temporarily circumvent this, execute this command &amp;lt;code&amp;gt;sysctl -w kernel.printk_ratelimit=0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next we check which services are running and listening to network sockets, but does not have profiles defined yet by running &amp;lt;code&amp;gt;aa-unconfined&amp;lt;/code&amp;gt;&lt;br /&gt;
In output you can see that there are some unconfined programs running. We skip perl because that is too generic, also SSH for now, and enable profiling for ProFTPD and some Dovecot subprocesses (we need to use full path for master process, because it is not in out $PATH).&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
aa-autodep proftpd&lt;br /&gt;
aa-autodep /usr/lib/postfix/sbin/master&lt;br /&gt;
aa-autodep dovecot&lt;br /&gt;
&lt;br /&gt;
Then run them in complain mode&lt;br /&gt;
&lt;br /&gt;
aa-complain dovecot&lt;br /&gt;
aa-complain proftpd&lt;br /&gt;
aa-complain /usr/lib/postfix/sbin/master&lt;br /&gt;
&lt;br /&gt;
Restart services&lt;br /&gt;
&lt;br /&gt;
systemctl restart postfix&lt;br /&gt;
systemctl restart dovecot&lt;br /&gt;
systemctl restart proftpd&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After that just proceed to do normal things, browse and send emails, create new folders in IMAP account, upload and download files thru ProFTPD. After you think you have done everything you wanted to allow, run &amp;lt;code&amp;gt;aa-logprof&amp;lt;/code&amp;gt; and generate profiles. &lt;br /&gt;
Lets mass enable generated profiles in enforce mode&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
aa-enforce /etc/apparmor.d/usr.lib.dovecot.*&lt;br /&gt;
aa-enforce /etc/apparmor.d/usr.lib.postfix*&lt;br /&gt;
aa-enforce proftpd&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reminder that enabling profiles in enforced mode might render your system unstable. You need to have a clear plan, what your system is going to do. How many users will be there, what will they want to do, etc.&lt;br /&gt;
&lt;br /&gt;
== Getting additional rules ==&lt;br /&gt;
You can download precreated AppArmor rules for most popular services by installing additional package&lt;br /&gt;
&amp;lt;code&amp;gt;apt install apparmor-profiles&amp;lt;/code&amp;gt;.&lt;br /&gt;
They are installed in same default directory /etc/apparmor.d as the rest of profiles.&lt;br /&gt;
&lt;br /&gt;
== Additional resources ==&lt;br /&gt;
* [http://wiki.apparmor.net/index.php/AppArmor_Core_Policy_Reference More about various policy flags]&lt;br /&gt;
* [http://wiki.apparmor.net/index.php/Documentation General documentation]&lt;br /&gt;
* [https://www.novell.com/documentation/apparmor/apparmor201_sp10_admin/data/bx5bmky.html Building Profiles from the Command Line]&lt;br /&gt;
* [https://help.ubuntu.com/community/AppArmor AppArmor Ubuntu wiki]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=OSadmin_wiki_article&amp;diff=120008</id>
		<title>OSadmin wiki article</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=OSadmin_wiki_article&amp;diff=120008"/>
		<updated>2017-04-10T21:07:00Z</updated>

		<summary type="html">&lt;p&gt;Srugam: /* Chosen topics */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Intro=&lt;br /&gt;
*Choose a topic from personal experience related with the subject or from topics found on the wiki page&lt;br /&gt;
*[[#Chosen_topics|Write the topic here]].&lt;br /&gt;
*Lecturer will confirm the topic&lt;br /&gt;
*Write your article in wiki environment &lt;br /&gt;
*Inform the [[Operating_systems#Lecturer|lecturer]] when the article is finished&lt;br /&gt;
*Receive feedback for corrections&lt;br /&gt;
&lt;br /&gt;
=Requirements for the wiki article=&lt;br /&gt;
Author: name, group and date when the article is written&lt;br /&gt;
&lt;br /&gt;
==Introduction ==&lt;br /&gt;
Covers points what will be discussed in the article, what are the requirements for the article reader; what are the operating system’s requirements. &lt;br /&gt;
&lt;br /&gt;
==Contents==&lt;br /&gt;
All commands should be easily separable from the overall text. &lt;br /&gt;
Users should be able to copy the commands directly (additional info like prompt and user distinction symbols should be left out from the command description area)&lt;br /&gt;
The text should determine what user permissions are needed to perform these tasks. &lt;br /&gt;
The reader of your article is your fellow students, so try to avoid irrelevant information and stay on topic (don’t explain the meaning of IP address or how to install Ubuntu, when your topic is actually about htop)&lt;br /&gt;
All the content should be referenced. &lt;br /&gt;
Do not use slang and try to be grammatically correct.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:#FF0000&amp;quot;&amp;gt; &lt;br /&gt;
Bear in mind that this is an open environment, so everything you write in your wiki article, will be public. &amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Referencing==&lt;br /&gt;
Best practises of wiki referencing should be used. &lt;br /&gt;
Terms are but between square brackets to reference other articles in the system.&lt;br /&gt;
All drawing and images have to be referenced below the picture and in the text. (for example “System architecture can be viewed on image x, y and z.”)&lt;br /&gt;
Author’s own ideas have to be clearly presentable. Everything used from the sources have to be referenced. &lt;br /&gt;
&lt;br /&gt;
==Fellow student review==&lt;br /&gt;
Please find a fellow student who will review your article and give a feedback on the discussion tab of the article using [http://enos.itcollege.ee/~edmund/materials/viki-artikkel/Assessment-model-for-the-wiki-article.html the following assessment model].&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
Besides a short overview, what was discussed in this article, it should also include the author&#039;s own opinion about the topic. &lt;br /&gt;
&lt;br /&gt;
==Category==&lt;br /&gt;
Add the following category to the end of the article (last row):&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;nowiki&amp;gt;[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=Chosen topics=&lt;br /&gt;
Please write here your topic and name, group:&lt;br /&gt;
* &#039;&#039;&#039;Basic Automation with Python&#039;&#039;&#039;; Ardi Vaba; CSE-11&lt;br /&gt;
* &#039;&#039;&#039;SSH Encryption&#039;&#039;&#039;; Frank Korving; CSE-11&lt;br /&gt;
* &#039;&#039;&#039;Translation of OSadmin wiki help page to English [[https://wiki.itcollege.ee/index.php/Osadmin_spikker]]&#039;&#039;&#039;; Peep Kuulme; CSE-11&lt;br /&gt;
* &#039;&#039;&#039;XSS Attack Vectors&#039;&#039;&#039;; Masaki Ihara; CSE-11&lt;br /&gt;
*[https://wiki.itcollege.ee/index.php/Auditd &#039;&#039;&#039;Auditd - Linux system monitoring with audit daemon&#039;&#039;&#039;], Nika Ptskialadze, CSE-11&lt;br /&gt;
* &#039;&#039;&#039;GNU Privacy Guard (GnuPG)&#039;&#039;&#039;; Patricia Bruno Barbosa; CSE-11&lt;br /&gt;
* &#039;&#039;&#039;BackBox OS&#039;&#039;&#039;; Ats Tootsi; CSE-11&lt;br /&gt;
*[https://wiki.itcollege.ee/index.php/creating_malware_lab &#039;&#039;&#039;How to create your own malware analysis lab&#039;&#039;&#039;], Mikus, CSE-11&lt;br /&gt;
*&#039;&#039;&#039;&#039;Arch Linux&#039;&#039;&#039;&#039;;Farhan Nayeem Islam;CSE-C11&lt;br /&gt;
* &#039;&#039;&#039;&#039;VPN basics&#039;&#039;&#039;&#039;, Christian Cataldo, CSE-C11; [https://wiki.itcollege.ee/index.php/VPN_(English_version)]&lt;br /&gt;
* &#039;&#039;Translation of DDoS Wiki page[[https://wiki.itcollege.ee/index.php/DDoS_Eng]]&#039;&#039;&#039;; Andris Männik; CSE-11&lt;br /&gt;
*&#039;&#039;&#039;Translation of Ps Wiki page[[https://wiki.itcollege.ee/index.php/Ps]]&#039;&#039;&#039;&#039;&#039;; Christopher Carr; CSE-11&lt;br /&gt;
*&#039;&#039;&#039;Translation of Bash_Shell wiki page[[https://wiki.itcollege.ee/index.php/BASH_shell]]&#039;&#039;&#039;; Steven Rugam; CSE-11&lt;br /&gt;
==Ideas==&lt;br /&gt;
* UNIX CLI password manager https://www.passwordstore.org and its GUI http://qtpass.org/&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Osadmin_referaadi_teemad counterpart article in Estonian]&lt;br /&gt;
* http://manpage.io&lt;br /&gt;
* https://linuxjourney.com/&lt;br /&gt;
* [https://linux.die.net/man/ Linux man-pages]&lt;br /&gt;
* [https://linux.die.net Linux docs]&lt;br /&gt;
* http://www.tecmint.com/60-commands-of-linux-a-guide-from-newbies-to-system-administrator/&lt;br /&gt;
* http://www.tecmint.com/useful-linux-commands-for-system-administrators/&lt;br /&gt;
* http://www.cyberciti.biz/tips/top-linux-monitoring-tools.html&lt;br /&gt;
* http://www.thegeekstuff.com/2010/12/50-unix-linux-sysadmin-tutorials&lt;br /&gt;
&lt;br /&gt;
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]]&lt;/div&gt;</summary>
		<author><name>Srugam</name></author>
	</entry>
</feed>