notes, references

May 23, 2007

unix – find files

Filed under: Linux, ubuntu, unix — karthik @ 5:47 pm
(most of the unix shell script have been taken from refs on the web andthe oreilly book unix-power-tools)
  1. Finding files that contains a particular word or string:
    1. $find . -name '*.css' -type f -print | xargs fgrep 'myParagraphStyle' /dev/null
    2. /dev/null – adding this makes grep print the match even if it just matches one file
    3. xargs – splits long set of arguments into chunks; this will prevent the command line exceeding any limits the command might have
    4. fgrep is same as ‘grep -F‘; this makes grep treat the search pattern as fixed strings separated by new lines any of which is to be matched
  2. Using what you find with exec
    1. $find . -name '*.css' -exec echo {} \;
    2. When not using xargs, -exec can be used to get find to execute a command on what it finds; the output of find can be given to another find command
    3. {} is a special argument that contains the name of the file – found by the find command
    4. Semicolon is used to indicate to find the end of the command that find has to execute; the semi-colon must be escaped either \; or ';' so all execs end with a semi-colon
    5. Example copying files
      $find /data/bkups/
      -name 'svn_2007-06-01.[0-9][0-9]'
      -exec sudo cp {}
      /media/bkupserver/svnbkups/svn_2007-06-01/ \;
  3. [placeholder]

May 21, 2007

Windows Shared folder from Ubuntu

Filed under: File Sharing, Linux, ubuntu — karthik @ 7:31 am

Ubuntu and windows file sharing is covered on so many web sites in great detail – searching for ubuntu Samba file sharing mount windows share etc will get many links

http://ubuntuforums.org/showthread.php?t=280473

http://ubuntuguide.org/wiki/Ubuntu:Feisty

http://doc.gwos.org/index.php/Share_files_using_Samba

http://ubuntuforums.org/showthread.php?t=202605

https://help.ubuntu.com/ubuntu/serverguide/C/configuring-samba.html#windows-networking-clients

All I want to do is mount a windows shared folder on my ubuntu box and access the files; I am not worried about mounting during boot up and not sharing any files from ubuntu.

  1. install smbfs
    1. $sudo apt-get install smbfs
  2. use ‘mount’ to mount the file share
    1. for mount you need to create a local folder that will be the mount point for example create a folder test under /media
    2. then mount the share using
      1. $sudo mount -t smbfs -o username=myusername //192.168.0.10/sharename /media/test
      2. myusername – is a valid username on the windows machine
      3. the ip address is the ip of the windows machine
      4. sharename is the name given to the share on the windows machine
      5. This will prompt you for the passwor d- the password for myusername on the windows machine
      6. on successful password you will be able to see the contents of the sharedfolder under /media/test
      7. Note: if you this is the first time you are using sudo in this shell session or if sudo has timed out there will be two password prompts first for the sudo next for the share mount. you could avoid this by doing $sudo -v before doing the sudo mount
  3. to umount
    1. $sudo umount /media/test

May 17, 2007

linux, ubuntu version

Filed under: Linux, ubuntu — karthik @ 9:33 pm

lsb_release (Linux Standard Base) prints system information with some distribution specific information
$lsb_release -a

uname prints system information like kernel info etc
$uname -a

Theme: Silver is the New Black. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.