Skip to main content

Posts

Showing posts from 2008

Workshop in Nihiluwa Vidyalaya

Conducted five days workshop in Visual Basic, Mambo (Content Management System) and Microsoft Access for student of Nihiluwa Maha Vidyalaya in 2008 October 16.       

Linux Commands - Part 5

du - This used to estimate file space usage. du /home  {shows usage of /home folder and all other files/folders in home folder} du -h /home {show usage in human readable foarmat. Using Mb and Gb} du –maxdepth=0 /home {show enrite /home folder usage only, sumerized one} du –maxdepth=1 /home  {show enrite /home folder and one level down} cut - This used to remove sections in each line. This is most of the time used with pipe command cat /etc/passwd | cut -d":"  -f1 cat /etc/passwd is to show content of the passwd file. We pipe output of that command cut using | (pipe). cut -d":" -f1 {this means split each line of out put by ':' and only display first field (f1)}. Thus if we take only first field we get username. Therefore above command list all the users in our system.  cat /etc/passwd | cut -d":" -f1-3 {show 1,2,3 field ,example :melick:x:1000} cat /etc/passwd | cut -d":"  -f1,3 {show 1 and 3 fields ,example :melick:1000} cat /etc/passwd

Linux Commands - Part 4

whoami   - This is used get who is the current user. hostname – This is used to get name of the machine. who           -Show who is logged into the system. Date           - Show the current date and time printenv  - Print vales o fall environment variables. env             -Print current environment. su -T his command is used to change the shell user.     su -            {change   the shell to the super user / root}    su - root    {change   the shell to the super user / root}    su - Saman        {change   the shell to the super Saman} id - This is used to print user's   information  id                       {show current user information}   id Saman           {show user Saman information} uname - This used to get machine and operating system information   uname               {show operating system}   uname -a           {show all info, OS, Kernel version, architecture}   uname   -r           {show kernel version} groups   -  T his us

Linux Commands - Part 3

find -This command is use t find files and folders   find . -name amal -print             {find amal in current directory and print output}  find /home -name a*   -print        {find things starts with a in /home directory and print output}   find /home -name a* -type d   -print       {find directories  starts with 'a' in /home directory and print output}   find /home -name a* -type f   -print        {find files starts with a in /home directory and print output}   find / -atime +7 -name *.conf -print  {find every thing end with “.conf” and access before last 7 days in / (root)}    find / -atime -7 -name *.conf -print  {find every thing end with “.conf” and access with in last 7 days in / (root)}    find / -atime 7 -name *.conf -print     {find every thing end with “.conf” and accessed  day 7 / (root)   f ind . -name meli -type f -exec rm {} \;  {find files  named 'meli' in current directory and remove  them}   Hints:     [-atime,-am

Linux Commands - Part 2

ls   - T his command is use to list files and folders.      ls                        {list current directory}    ls /media           {list /media files and folders in   directory media }    ls -l                     {list permission}    ls -a                   {list all, including hidden files, etc} c p - T his command is use to copy files and folders     cp   test /home/melick { copy test file to /home/melick folder}      cp   /root/s.txt   .          {copy s.txt to current directory (.)}      cp -r /root   /home/melick         {copy entire root folder to melick}                   mv - T his is used t move and rename files and folders     mv   test /home/melick         { move test file to /home/melick folder}    mv   /root/s.txt   .      { move s.txt file in /root to current folder (.)}    mv test1 test2             {rename test1 file to test2}            rm - This is used t delete files and folders    rm /home/Melick/tes t       {delete the test file

Linux Commands - Part 1

chmod -  this is the command hat we use to change the permission.  ex:- chmod 777  test {change the permission to 777 the file test in the current directory} chmod 777 /home/melick/test {change the permission to 777 the file test in the /home/melick directory} chmod   g-r test {remove read permission in the group} chmod   g+r test {add read permission in the group} chmod   o-r test {remove read permission in the other} chmod   o+r test {add read permission in the other} chmod   u-r test {remove read permission in the user/owner} chmod   u+r test {add read permission in the user/owner} chmod   u=r test {read permission only to the user/owner} chmod   u=w test {write permission only to the user/owner} chown -  this command is use to change the owner of the file. chown root test     { if we want to change ownership to the file to the root } -rw-r--r-- 1 root melick 0 2008-12-21 21:11 test chown Melick:Sachika test {change 'test' files

Linux Permissions

In linux, file, folder, etc can accesse by three types of user groups. Owner Group Other and each user group has three types of permissions. read,write, and execute. As an example, (if user has read permision we denote it by using 1 and if not by 0 in binary ) Owner Group Other rwx    rw-      r--  111     110     100  7         6          4 we can use " ls -l " command to view files,folders,links with permissions. drwxr-xr-x 2 melick melick 4096 2008-11-23 00:32 Music this is the sample. so we look each and every element further. drwxr-xr-x first charactor "d" is for type of the file. there are three types. d = directory (folder) l = link (symbolic link, shortcut) - = file c = charactor device (ex:- /dev/ttys0) {try:- ls -l /dev/ttys0} b = block device (ex:- /dev/sda1)     {try:- ls -l /dev/sda1} now we consider the permission set in the above folder. rwxr-xrx- = rwx   r-x        r-x   owner  group   other   111       101       101   7           5      

About Linux Users

All linx users, their passwords and other details are stored in a one file. It is " passwd " file which is in the "etc" folder. { /etc/passwd }             If we want to view password file {hm... there are several ways, but for the moment we will use "cat" command}.we will talk about "cat" command later. So in your command prompt {shell,terminal} run below command.  cat /etc/passwd This command will give you a file with several rows. One row is for one user. Let have a look on one row.  melick:x:1000:1000:melickrajee:/home/melick:/bin/bash  So let see what this line says. Following illustrate the format of the one line              username:password:Gid:Uid:Fullname:home folder:shell  So now we compare those two for further details.  melick       :x               :1000 :1000  :melickrajee  :/home/melick :/bin/bash  username :password :Gid    :Uid     :Fullname     :home folder  :shell melick - Username x(password) - x is not the pass