Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts
Mounting a Windows Shared Folder with Write Permissions
Use the following commands
http://www.howtogeek.com/176471/how-to-share-files-between-windows-and-linux/
http://askubuntu.com/questions/72471/correct-way-of-mounting-a-windows-share
sudo mount.cifs //COMPUTER_NAME_OR_IP/FOLDERNAME /PATH/TO/MOUNT/LOCATION/ -o user=USERNAME,iocharset=utf8,file_mode=0777,dir_mode=0777These were learned from the following two websites:
http://www.howtogeek.com/176471/how-to-share-files-between-windows-and-linux/
http://askubuntu.com/questions/72471/correct-way-of-mounting-a-windows-share
rsh
I found a great article on setting up rsh here: http://people.redhat.com/kzak/docs/rsh-rlogin-howto.html
SVN Server on Mavericks - OS X Server
Great instructions here
http://pablotips.blogspot.com/2013/12/install-svn-on-mac-os-x-again-this-time.html
First run this
Then run these
Here are a few links that I found helpful when setting things up
https://discussions.apple.com/thread/5283885
http://superuser.com/questions/691808/how-to-customize-mavericks-mac-osx-server-apache-configuration
http://support.apple.com/kb/ht4813
First run this
xcode-select --installThen get the matching version of subversion already installed
Then run these
./configureand then run these
make
sudo cp subversion/mod_dav_svn/.libs/mod_dav_svn.so /usr/libexec/apache2/.
sudo cp subversion/mod_authz_svn/.libs/mod_authz_svn.so /usr/libexec/apache2/.
sudo ln -s /Applications/Xcode.app/Contents/Developer/usr/lib/libsvn_repos-1.0.dylib /usr/local/lib/libsvn_repos-1.0.dylibAlso note that if you are using OS X Server, the httpd.conf file in /etc/apache2 is no longer used. Rather, all the configuration files are located in /Library/Server/Web/Config/apache2 (Or something very close to this). Therefore, all the httpd-svn.conf and other files must be placed in the Other folder inside this directory.
sudo ln -s /Applications/Xcode.app/Contents/Developer/usr/lib/libsvn_fs-1.0.dylib /usr/local/lib/libsvn_fs-1.0.dylib
sudo ln -s /Applications/Xcode.app/Contents/Developer/usr/lib/libsvn_fs_fs-1.0.dylib /usr/local/lib/libsvn_fs_fs-1.0.dylib
sudo ln -s /Applications/Xcode.app/Contents/Developer/usr/lib/libsvn_fs_util-1.0.dylib /usr/local/lib/libsvn_fs_util-1.0.dylib
sudo ln -s /Applications/Xcode.app/Contents/Developer/usr/lib/libsvn_delta-1.0.dylib /usr/local/lib/libsvn_delta-1.0.dylib
sudo ln -s /Applications/Xcode.app/Contents/Developer/usr/lib/libsvn_subr-1.0.dylib /usr/local/lib/libsvn_subr-1.0.dylib
# Optional ? sudo ln -s /Applications/Xcode.app/Contents/Developer/usr/lib/libsvn_wc-1.0.dylib /usr/local/lib/libsvn_wc-1.0.dylib
sudo ln -s /Applications/Xcode.app/Contents/Developer/usr/lib/libsvn_client-1.0.dylib /usr/local/lib/libsvn_client-1.0.dylib
sudo ln -s /Applications/Xcode.app/Contents/Developer/usr/lib/libsvn_diff-1.0.dylib /usr/local/lib/libsvn_diff-1.0.dylib
sudo ln -s /Applications/Xcode.app/Contents/Developer/usr/lib/libsvn_ra-1.0.dylib /usr/local/lib/libsvn_ra-1.0.dylib
sudo ln -s /Applications/Xcode.app/Contents/Developer/usr/lib/libsvn_ra_local-1.0.dylib /usr/local/lib/libsvn_ra_local-1.0.dylib
sudo ln -s /Applications/Xcode.app/Contents/Developer/usr/lib/libsvn_ra_neon-1.0.dylib /usr/local/lib/libsvn_ra_neon-1.0.dylib
sudo ln -s /Applications/Xcode.app/Contents/Developer/usr/lib/libsvn_ra_serf-1.0.dylib /usr/local/lib/libsvn_ra_serf-1.0.dylib
sudo ln -s /Applications/Xcode.app/Contents/Developer/usr/lib/libsvn_ra_svn-1.0.dylib /usr/local/lib/libsvn_ra_svn-1.0.dylib
Here are a few links that I found helpful when setting things up
https://discussions.apple.com/thread/5283885
http://superuser.com/questions/691808/how-to-customize-mavericks-mac-osx-server-apache-configuration
http://support.apple.com/kb/ht4813
Opening a Port in the Firewall
Instructions found here
http://www.cyberciti.biz/faq/howto-rhel-linux-open-port-using-iptables/
Linux Cheat Sheet
I found a cool cheat sheet at this website http://linoxide.com/linux-command/linux-commands-cheat-sheet/ Here is a PDF version
run a single script as root user
The following text is take from http://askubuntu.com/questions/167847/how-to-run-bash-script-as-root-with-no-password
There is a very neat trick in every Linux which will allow you to do so. It is called the SetUI bit.
Keep in mind that you will need to have the permissions locked down tight in this file for this to be secure.
Make the file owned by root and group root:
The SetUID bit makes a script or binary always run as the owner of the file/binary, an example of such a binary is 'passwd'.
There is a solution using sudoers here is an example you could use:
There is a very neat trick in every Linux which will allow you to do so. It is called the SetUI bit.
Keep in mind that you will need to have the permissions locked down tight in this file for this to be secure.
Make the file owned by root and group root:
Now set the sticky but, make it executable for all and writable only by root:sudo chown root.root <my script>
Keep in mind if this script will allow any input or editing of files, this will also be done as root.sudo chmod 4755 <my script>
The SetUID bit makes a script or binary always run as the owner of the file/binary, an example of such a binary is 'passwd'.
There is a solution using sudoers here is an example you could use:
Now just place sudo in front of your script and it should run without asking for a password.Cmnd_Alias CMDS = /path/to/your/script <username> ALL=NOPASSWD: CMDS
Sending mail from the command line
I found a nice tutorial here: http://www.simplehelp.net/2008/12/01/how-to-send-email-from-the-linux-command-line/
httpd auth
The following instructions are for providing authorization to an svn repository and come from the SVN Redbean book.
First, create a password file and grant access to users Harry and Sally:
First, create a password file and grant access to users Harry and Sally:
$ ### First time: use -c to create the fileIt's important to remember that -c is only used the first time to create the file.
$ ### Use -m to use MD5 encryption of the password, which is more secure
$ htpasswd -c -m /etc/svn-auth.htpasswd harry
New password: *****
Re-type new password: *****
Adding password for user harry
$ htpasswd -m /etc/svn-auth.htpasswd sally
New password: *******
Re-type new password: *******
Adding password for user sally
$
ssl - https
I'm in the process of setting up a secure server and I have found some helpful instructions for getting a self-signed certificate here and here.
I had to yum install mod_dav_svn and mod_ssl so I could setup an https connection to my server. Then I installed the certificates in /etc/httpd/conf.d and pointed the ssl.conf file in that folder to the certificates and that was it.
I edited the httpd.conf file so that it doesn't listen to port 80 (no http) and added the following text
I had to yum install mod_dav_svn and mod_ssl so I could setup an https connection to my server. Then I installed the certificates in /etc/httpd/conf.d and pointed the ssl.conf file in that folder to the certificates and that was it.
I edited the httpd.conf file so that it doesn't listen to port 80 (no http) and added the following text
# Subversion settingFinally, I only opened port 443 for https on the firewall.
<Location /svn>
DAV svn
SVNParentPath /path/to/svn/repos
# Authentication: Basic
AuthName "Subversion repository"
AuthType Basic
AuthUserFile /path/to/auth/file
# Authorization: Authenticated users only
Require valid-user
</Location>
ssh config
I recently discovered a convenient shortcut for ssh hosts which works on a Mac but I expect it should work on any *nix system. In the ~/.ssh folder you can create a file called config and add the following lines:
Host nicknameThen when you want to ssh to that server you only have to type
Hostname ipaddress.or.hostname
User username
ssh nicknameand the remaining information is automatically added.
sed
sed is a great command line tool for *nix operating systems. There's a great tutorial on it here.
I definitely don't use it to it's full potential but it's convenient for stripping parts of a file out. Say you want to get a part between two key words, use this
Alternatively, you can use the ! (not) sign to do the opposite. For example, say I want to keep everything between lines 1-10 and put that into a file, use this
I definitely don't use it to it's full potential but it's convenient for stripping parts of a file out. Say you want to get a part between two key words, use this
sed -e '1,/StartKeyword/ d' -e '/EndKeyword/,$ d' in.txt > out.txtThis command says to delete everything from line 1 to 'StartKeyword' and then to delete everything from 'EndKeyword' to the end of the file '$' and to put it into out.txt.
Alternatively, you can use the ! (not) sign to do the opposite. For example, say I want to keep everything between lines 1-10 and put that into a file, use this
sed -e '1,10 !d' in.txt > out.txtSo, sed becomes quite convenient for working with large text files, and I haven't even begun to scratch the surface of what it can do.
Mount ISO image in Linux
The following text is taken from http://www.cyberciti.biz/tips/how-to-mount-iso-image-under-linux.html
Procedure to mount ISO images under Linux
1) You must login as a root user, if not root user then switch to root user using following command:$ su -2) Create the directory i.e. mount point:
$ mkdir -p /mnt/disk3) Use mount command as follows to mount iso file called disk1.iso:
$ mount -o loop disk1.iso /mnt/disk4) Change directory to list files stored inside an ISO image:
$ cd /mnt/disk
$ ls -l
More about loop device
A loop device is a pseudo-device that makes a file accessible as a block device. Loop devices are often used for CD ISO images and floppy disc images. Mounting a file containing a filesystem via such a loop mount makes the files within that filesystem accessible. They appear in the mount point directory using above commands.Partitioning, Formatting and Mounting Linux Drives
This comes from http://www.linux-gujarat.co.in/e107_plugins/content/content.php?content.46 and most of the content is quoted with slight changes:
So let's start
Current HDD configuration i have 40GB IDE in my box ..!!!
Step : 1 Create Extended Paritition
In Linux there is various file support if u want to create ext2 or ext3 file system there is specially command to create special file system....
Step 3:Format newly created partition
Logical patition is formatted with EXT3 file system only thing left i have to mount ....
I am creating directory ... and then i will mount this whole 160 GB @ that directory as mount pt ....
Step 4 : Mount formated partition in my Linux box !
So let's start
[root@GLUG ~]# fdisk -l /dev/hda
Disk /dev/hda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
[root@GLUG ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
37G 28G 7.0G 80% /
/dev/hdb1 99M 9.0M 85M 10% /boot
none 375M 0 375M 0% /dev/shm
FDISK command shows you disk partition details...
[root@GLUG ~]# fdisk -l /dev/hdb
Disk /dev/hdb: 40.0 GB, 40020664320 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hdb1 * 1 13 104391 83 Linux
/dev/hdb2 14 4865 38973690 8e Linux LVM
Now i have to conduct following task to use new HDD
1) Create Extended Paritition
2 ) Create Logical partition
3) Format newly created partition
4) Mount formated partition in my Linux box !
1) Create Extended Paritition
2 ) Create Logical partition
3) Format newly created partition
4) Mount formated partition in my Linux box !
Step : 1 Create Extended Paritition
[root@GLUG ~]# fdisk /dev/hda
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition\'s system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
As i have already primary partition and Linux is booting from there..so it doesn't make sense to create primary partition..As i will going to use this whole new space for data saving...
( i m not going to in detail what extended and logical and why logical needs to be created !!! HOPE u all guys n gals know already )
Step 2 : Creating new Logical partition under Extended partition we created...
Now i am going format this newly created logical partition..... using mkfs command... Command (m for help): nViewing partition ....which i created !!
Command action
e extended
p primary partition (1-4)
e
Partition number (1-4): 1
First cylinder (1-19457, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-19457, default 19457):
Using default value 19457
Command (m for help): pExtended partition won't help or useful or OS can not use. We must have to create logical partition... so i m going to do next ....
Disk /dev/hda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 1 19457 156288321 5 Extended
( i m not going to in detail what extended and logical and why logical needs to be created !!! HOPE u all guys n gals know already )
Step 2 : Creating new Logical partition under Extended partition we created...
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition\'s system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l ( i pressed L (Small )
First cylinder (1-19457, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-19457, default 19457):
Using default value 19457
Command (m for help): p
Disk /dev/hda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 1 19457 156288321 5 Extended
/dev/hda5 1 19457 156288289+ 83 Linux
Saving partition Table !!!!
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
In Linux there is various file support if u want to create ext2 or ext3 file system there is specially command to create special file system....
Step 3:Format newly created partition
[root@GLUG ~]# mkfs -t ext3 /dev/hda5
mke2fs 1.35 (28-Feb-2004)
max_blocks 4294967295, rsv_groups = 0, rsv_gdb = 1024
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
19546112 inodes, 39072072 blocks
1953603 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=41943040
1193 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
Writing inode tables: done
inode.i_blocks = 122888, i_size = 4243456
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 20 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
I am creating directory ... and then i will mount this whole 160 GB @ that directory as mount pt ....
Step 4 : Mount formated partition in my Linux box !
[root@GLUG ~]# mkdir /GLUG
[root@GLUG ~]# mount /dev/hda5 /GLUG/
[root@GLUG ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
37G 28G 7.0G 80% /
/dev/hdb1 99M 9.0M 85M 10% /boot
none 375M 0 375M 0% /dev/shm
/dev/hda5 147G 93M 140G 1% /GLUG
bash script
Occasionally I need to write bash scripts and just wanted to jot down some notes that are helpful when doing that.
The first line of the script should read
And then you can check the number of command line arguments that are passed into the script with
The first line of the script should read
#!/bin/bash
And then you can check the number of command line arguments that are passed into the script with
$#and then the arguments can be accessed by using
$1 or $2, etc.and the name of the script can be accessed with
$0and finally, all the command line arguments can be accessed with
$@
chmod codes
I have a hard time remembering the number codes for changing permissions with chmod so I'm listing them here
0 = --- = no accessThese were obtained from the following site, where additional information is available.
1 = --x = execute
2 = -w- = write
3 = -wx = write and execute
4 = r-- = read
5 = r-x = read and execute
6 = rw- = read and write
7 = rwx = read write execute (full access)
screen
Occasinally I want to keep processes running in Linux after I have logged out of a session. This can be done by making the process run in the background by putting the "&" sign after the process you want executed and then pressing pound. This gives no interactivity though and the process must run on its own. There's also the command
I discovered the command
nohupwhich runs the process in the background and then prints out all output to a specified file, but again, no interactivity.
I discovered the command
screenwhich allows one to keep a shell process running but attach and detach it from different login sessions, thus allowing interactivity at any time. There are several commands that have to be learned but they're very simple and provides a great degree of freedom with the Linux operating system. A basic introduction to GNU screen can be found here.
Subversion
A long time ago I heard about version control tracking, or software that can keep track of changes to documents so that you don't have to, and thought it sounded pretty cool, but until about a year ago, I had never used it. Well, I love it. It makes it so much easier to code when you know that every time you commit a change it will be saved and so if you make any undesirable changes you can always roll back to a version that works. It has also made my programming much more focused because I work on fixing one bug at a time and after I fix that bug, I commit that change and work on the next. It's much easier to isolate problems with the code and have confidence that I am keeping track of my past work. My preferred software is Subversion or SVN and comes standard with most Linux packages. I just recently discovered a port to Windows that I really like called TortoiseSVN which is implemented as a Windows shell extension, for seamless integration into Windows Explorer. I really like it so far and even provides for tracking of other non-text file formats such as '.doc' and '.xls'. I searched to see if there's something similar for OSX and found this post which refers to a plugin called SCPlugin. Although I haven't used it yet, it appears to be integrated with Finder. Anyways, I'm excited to try it out.
Subscribe to:
Posts (Atom)
