Showing posts with label LINUX TIPS. Show all posts
Showing posts with label LINUX TIPS. Show all posts

Tuesday, 25 October 2011

Prevent others from browsing your files

In a multiuser server environment, set diretories to these settings to prevent others from browsing your files: (read/write/execute by owner, & only execute by others, no read/write/execute by group)

e.g.
Read Write eXecute

Owner Access On On On
Group Access Off Off Off
Other Access Off Off On

chmod 711 /usr/home/USERNAME/
chmod 701 /usr/www/users/USERNAME/

Saturday, 22 October 2011

Resolve "device is busy" error when doing a umount



If get "device is busy" when doing a umount, e.g.:

[root@server/]# umount /home/data/
umount: /home/data: device is busy


To find out who's still using the share, do a, e.g.:

[root@orion /]# fuser -u -v /home/data/

USER PID ACCESS COMMAND
/home/data/ root 15376 ..c.. vim

Friday, 21 October 2011

Use ls -h to show Kilobyte, Megabyte, Gigabyte, etc

Use the -h switch when doing an ls to get a more readable filesize value (K for kilobyte,

M for megabyte, G for gigabyte), e.g.:

[root@server backup]# ls -altrh
total 9.4G
drwxr-xr-x 2 4294967294 4294967294 4.0K Oct 6 2004 last.txt
-rw-r--r-- 1 4294967294 4294967294 4.3G Oct 6 2004 backup.tgz
-rw-r--r-- 1 4294967294 4294967294 843M Nov 23 14:31 backup_20041123.tgz
-rw-r--r-- 1 4294967294 4294967294 863M Dec 4 02:33 backup_20041204.tgz
-rw-r--r-- 1 4294967294 4294967294 5.9M Jan 17 01:55 20050117.tgz
-rw-r--r-- 1 4294967294 4294967294 928M Jan 17 02:49 backup_20050117.tgz
-rw-r--r-- 1 4294967294 4294967294 960M Feb 2 15:03 backup_20050202.tgz
drwxr-xr-x 23 root root 4.0K Feb 25 18:12 ..
drwxrwxrwx 3 root root 4.0K Apr 3 01:28 .
-rw-r--r-- 1 4294967294 4294967294 1.6G Apr 3 03:36 backup_20050403.tgz
[root@server backup]#

Delete a range of lines in Vim example

In vim, to delete a range of lines, e.g. lines 10 through line 290, do a:

:10,290d

Rename file starting with a dash(-)

If having problem renaming a file that starts with a dash:

Since the file name begins with a '-' it looks like an option to the
command. You need to force it to not look like an option. Put a ./
in the front of it. Or give it the full file name path. Or tell the
command you are through with options by using the double dash to end
all option processing. This is common to most traditional UNIX
commands.

cp ./* /some/folder
cp -- * /some/folder

And the same for other utilities too.

mv ./-stuff differentstuff
mv -- -stuff differentstuff

Tuesday, 18 October 2011

ulimit example



[root@server conf]# ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
pending signals (-i) 1024
max locked memory (kbytes, -l) 32
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 4095
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited

[root@server conf]# ulimit -a | grep files
open files (-n) 1024

Change (example of increasing to 5000 files):

ulimit -n 5000