Linux Tricks: Difference between revisions

From Braindisconnect
Jump to navigationJump to search
(Created page with "== gzip files == This will gzip all files within a directory that are not already compressed. find . -type f ! -name '*.gz' -exec gzip "{}" \; == List only files == This is...")
 
No edit summary
 
Line 1: Line 1:
[[Category:Linux]]
== gzip files ==
== gzip files ==
This will gzip all files within a directory that are not already compressed.
This will gzip all files within a directory that are not already compressed.
Line 49: Line 50:


You will want to lock the nfs down to certain IP addresses on the server. It usually is not a good idea to make the same share a cifs share and a nfs share.  You'll run into a lot of issues.
You will want to lock the nfs down to certain IP addresses on the server. It usually is not a good idea to make the same share a cifs share and a nfs share.  You'll run into a lot of issues.
[[Category:Misc]]

Latest revision as of 20:01, 14 March 2015

gzip files

This will gzip all files within a directory that are not already compressed.

find . -type f ! -name '*.gz' -exec gzip "{}" \;

List only files

This is used to get just the files in a dir. Great for redirecting to a file.

ls -la | tr -s " " | cut -d " " -f9


Change all files to Lowercase

for SRC in `find my_root_dir -depth`
do
    DST=`dirname "${SRC}"`/`basename "${SRC}" | tr '[A-Z]' '[a-z]'`
    if [ "${SRC}" != "${DST}" ]
    then
        [ ! -e "${DST}" ] && mv -T "${SRC}" "${DST}" || echo "${SRC} was not renamed"
    fi
done


Mount CIFS

Install cifs utils:

apt-get install -y cifs-utils

Make a dir to attach the share to:

mkdir /mnt/cifsshare

In /etc/fstab add this line to the end of the file:

//192.168.1.30/cifsshare/ /mnt/cifsshare cifs uid=0,guid=0,rw,credentials=/etc/cifspasswd,workgroup=<your workgroup> 0 0

Make a file named /etc/cifspasswd and put the username and password in the file

username=user
password=password

Change the '/etc/cifspassword' file's owner and permissions:

chown 0.0 /etc/cifspasswd
chmod 600 /etc/cifspasswd

It usually is not a good idea to make the same share a cifs share and a nfs share. You'll run into a lot of issues.

Mount NFS

Make a dir to attach the share to:

mkdir /mnt/nfsshare

In /etc/fstab add this line to the end of the file:

192.168.1.50:/mnt/nfsshare /mnt/nfsshare nfs rw,rsize=8192,hard,intr,nfsvers=3,tcp,noatime,nodev,async 0 0

You will want to lock the nfs down to certain IP addresses on the server. It usually is not a good idea to make the same share a cifs share and a nfs share. You'll run into a lot of issues.