Utilities: CHMOD
Typical Chmod permissions values:664 or -rw-r–r– web pages and images viewed by surfers. What is Owner, Group and Other?Owner – the user/owner of a file or directory. |
By using this calculator you agree that we are not liable for anything that may happen by your use.
__________________________________________________________________________
More about chmod
Changes the permission of a file.
Syntax
chmod [OPTION]… MODE[,MODE]… FILE…
chmod [OPTION]… OCTAL-MODE FILE…
chmod [OPTION]… –reference=RFILE FILE…
-c, –changes like verbose but report only when a change is made
–no-preserve-root do not treat `/’ specially (the default)
–preserve-root fail to operate recursively on `/’
-f, –silent, –quiet suppress most error messages
-v, verbose output a diagnostic for every file processed
–reference=RFILE use RFILE’s mode instead of MODE values
-R, –recursive change files and directories recursively
–help display this help and exit
–version output version information and exit
Permissions
u – User who owns the file.
g – Group that owns the file.
o – Other.
a – All.
r – Read the file.
w – Write or edit the file.
x – Execute or run the file as a program.
Numeric Permissions:
CHMOD can also to attributed by using Numeric Permissions:
400 read by owner
040 read by group
004 read by anybody (other)
200 write by owner
020 write by group
002 write by anybody
100 execute by owner
010 execute by group
001 execute by anybody
Examples
The above numeric permissions can be added to set a certain permission, for example, a common HTML file on a Unix server to be only viewed over the Internet would be:
chmod 644 file.htm
This gives the file read/write by the owner and only read by everyone else (-rw-r–r–).
Files such as scripts that need to be executed need more permissions. Below is another example of a common permission given to scripts.
chmod 755 file.cgi
This would be the following 400+040+004+200+100+010+001 = 755 where you are giving all the rights except the capability for anyone to write to the file.cgi file(-rwxr-xr-x).
chmod 666 file.txt
Finally, another common CHMOD permission is 666, as shown below, which is read and write by everyone.
Additional information
Below is an example of how a file may be listed when typing ( ls -l ) at the prompt as well as information on how to interpret it.
-rw-rw-r– 1 selene 123 Feb 03 15:36 file.txt
– | rw | rw- | r– | 1 | selene | 123 | Feb 03 15:36 | file.txt |
File | owner | group | everyone else | links | owner | size | mod date | file name |
Linux: Joining .avi or .mpg files together using mencoder
Program installation:
sudo apt-get install mencoder mplayer
You may want to rename your video files to make life easier.
If you are use to using ” you can go the following:
cat video1.mpg video2.mpg video3.mpeg > video.avi
After they are put together use mencoder to sync the video with the audio:
mencoder -forceidx -oac copy -ovc copy video.mpg -o finalvideo.mpg
An easier method is:
mencoder -oac copy -ovc copy video1.mpg video2.mpg video3.mpeg -o finalvideo.mpg
Linux: Putting two or more files together using cat
Many people are familiar with the “cat” command. Most of us use it when dealing with text and logging.
This command can also be use to put multiple video files together.
Example:
cat video1.mpg video2.mpg > finalvideo.mpg
This is best when using video without audio.
If putting two video files together that have audio you will need to sync the video and sound with a program like mencoder.
cat command options:
cat [OPTION] [FILE]…
Description
Concatenate FILE(s), or standard input, to standard output.
- -A, –show-all
- equivalent to -vET
- -b, –number-nonblank
- number nonblank output lines
- -e
- equivalent to -vE
- -E, –show-ends
- display $ at end of each line
- -n, –number
- number all output lines
- -s, –squeeze-blank
- never more than one single blank line
- -t
- equivalent to -vT
- -T, –show-tabs
- display TAB characters as ^I
- -u
- (ignored)
- -v, –show-nonprinting
- use ^ and M- notation, except for LFD and TAB
- –help
- display this help and exit
- –version
- output version information and exit
With no FILE, or when FILE is -, read standard input.
Examples
- cat f – g
- Output f’s contents, then standard input, then g’s contents.
- cat
- Copy standard input to standard output.
Linux: How to flush DNS in Ubuntu
Sometimes you need to see the changes that have been made on a DNS server, but these changes are stuck in your workstation DNS cache.
Similar to Windows ipconfig /flushdns you can flush your Linux computers DNS.
You must first install the name service cache daemon (nscd). This is not usually installed by default.
After the install is complete you can simply restart the nscd as need to clean your DSN cache.
- sudo apt-get install nscd
- Flush DNS Cache in Ubuntu Using the following command
- sudo /etc/init.d/nscd restart
Linux: Mounting a partition within a disk image using NASA patch (for older systems)
If you are using util-linux prior to version 2.12b, specifying an offset that required more than 32-bits was not possible.
Attempting to mount my ext3 partition near the end of the disk with a 2.11 version of util-linux yields (7695198 * 512 = 3939941376):
faith:/usr/src# mount -o loop,offset=3939941376
-t ext3 /nebula/hda_dd.image /mnt
mount: wrong fs type, bad option, bad superblock on /dev/loop0,
or too many mounted file systems
Fortunately, we aren’t done yet. The second method utilizes a loopback device designed to mount partitions within the image without an offset limitation. In fact, no offset need be specified at all.
Mounting with a Special Patch
As this was written back in 2004, I do not believe the NASA loopback patch is still around.
You will need to patch your kernel to use the enhanced loopback device. This patch alters the way the loopback device works. You will no longer be able to mount partitions via the loopback device beyond /dev/loop0. If you use /dev/loop[1-7] this could be a show stopper for you; Check out the last method.
The patch is currently available against 2.4.20 and 2.4.21 prepatch 4. You will need to fetch the patch from NASA HQ’s public FTP server. It’s the enhanced_loop-x.x-linux-2.4.x-xfs.patch file located there. You can also fetch the XFS patch for 2.4.21-pre4 and the 2.4.21-pre4 patch itself as of this writing. I used 2.4.21-pre4 with Alan Cox’s -ac7. For convenience, a patched kernel ready for compiling is also available.
faith:/usr/src/linux-2.4.20# patch
-p1 < ../enhanced_loop-0.2-linux-2.4.21-pre4-xfs.patch
patching file drivers/block/loop.c
patching file Makefile
Hunk # 1 FAILED at 1.
1 out of 1 hunk FAILED — saving rejects to file Makefile.rej
Don’t worry about the Makefile reject; It’s just the EXTRA_VERSION variable. (That’s because I used -ac7.)
Now, recompile your kernel in the usual way (I use Debian GNU/Linux’s make-kpkg command) and make sure you enable the loopback device if it isn’t already. When that task is complete, reboot with your shiny new kernel.
To accomodate the enhanced loopback device, some new entries need to be created in /dev. A script named createdev is available to handle that task for you, and it can be run at start up if you’re running devfs to recreate the entries for you at boot. You can fetch the script from NASA HQ. You may need to comment out the sourcing of the RedHat functions within the script if you aren’t on a RedHat based distribution, like Debian. By default the script will create enough entries in /dev for a fifteen disks with up to fifteen partitions. You can adjust that to your requirements within the script. It will blow away any existing /dev entries it has added if you change configurations, so you need not tend to them yourself.
faith:/nebula# vi createdev
faith:/nebula# bash createdev start
faith:/nebula#
Once you’ve run the script, you should find a entries like the following in your /dev directory:
faith:/# ls /dev/loop[a-zA-Z]*
/dev/loopa /dev/loopd12 /dev/loopg2
/dev/loopj6 /dev/loopn /dev/loopa1
/dev/loopd13 /dev/loopg3 /dev/loopj7
/dev/loopn1 /dev/loopa10 /dev/loopd14
/dev/loopg4 /dev/loopj8 /dev/loopn10
/dev/loopa11 /dev/loopd15 /dev/loopg5
/dev/loopj9 /dev/loopn11
With the kernel up and running, you also need to acquire a modified copy of losetup, the loopback setup program. If you’re running an RPM based distribution, you’re in luck. You can fetch the modified losetup by making another journey to NASA HQ’s FTP server. Rebuild it with rpmbuild -bb and install. If you’re running Debian GNU/Linux, as I am, you can install the rpm package with the usual apt-get command. Then, you could either build the RPM package and use alien to convert it to a Debian package or use rpm2cpio to create a cpio archive of the RPM. For the latter, you can extract the source from the resultant cpio archive and compile:
faith:/usr/src# rpm2cpio loop-utils-0.0.1-1.src.rpm > loop-utils.cpio
faith:/usr/src# cpio -i < loop-utils.cpio
39 blocks
faith:/usr/src# tar -zxvf loop-utils-0.0.1.tar.gz
loop-utils-0.0.1/
loop-utils-0.0.1/COPYING
loop-utils-0.0.1/Makefile
loop-utils-0.0.1/loimginfo.c
loop-utils-0.0.1/lomount.c
loop-utils-0.0.1/lomount.h
loop-utils-0.0.1/loop.h
loop-utils-0.0.1/loop.sgml
loop-utils-0.0.1/losetgeo.c
loop-utils-0.0.1/lotest.c
loop-utils-0.0.1/nls.h
loop-utils-0.0.1/partinfo.c
faith:/usr/src# cd loop-utils-0.0.1
You may wish to edit the Makefile, which sticks things in /usr by default. I changed it to /usr/local and added ${prefix} as the path for the sbin_prefix variable. It originally had no value at all, but is later used when installing the losetup binary, which would instead end up in your /sbin directory. Oops.
faith:/usr/src/loop-utils-0.0.1# make
gcc -Wall -Wstrict-prototypes -O6 -DVERSION='”0.3.9″‘
-DLOG2_NR_PARTITION=’4’ -c -o losetgeo.o losetgeo.c
gcc losetgeo.o -o losetgeo
gcc -Wall -Wstrict-prototypes -O6 -DVERSION='”0.3.9″‘
-DLOG2_NR_PARTITION=’4’ -c -o loimginfo.o loimginfo.c
gcc loimginfo.o -o loimginfo
gcc -Wall -Wstrict-prototypes -O6 -DVERSION='”0.3.9″‘
-DLOG2_NR_PARTITION=’4’ -c -o partinfo.o partinfo.c
gcc partinfo.o -o partinfo
gcc -DMAIN -D_FILE_OFFSET_BITS=64 lomount.c -o losetup.o
<warnings…>
ld losetup.o -o losetup
gcc -Wall -Wstrict-prototypes -O6 -DVERSION='”0.3.9″‘
-DLOG2_NR_PARTITION=’4’ -c -o lotest.o lotest.c
gcc lotest.o -o lotest
sgml2latex loop.sgml
Processing file loop.sgml
sgml2html -s 0 loop.sgml
Processing file loop.sgml
sgml2info loop.sgml
Processing file loop.sgml
echo “START-INFO-DIR-ENTRY” > loop.info.2
echo “* Loop: (loop). Block device loopback package.”
>> loop.info.2
echo “END-INFO-DIR-ENTRY” >> loop.info.2
cat loop.info.2 loop.info > loop.info.3
rm loop.info.2
mv loop.info.3 loop.info
Now, let’s test drive our new loopback device.
faith:/nebula# /usr/local/sbin/losetup -d /dev/loopa
faith:/nebula# /usr/local/sbin/losetup /dev/loopa hda_dd.image
faith:/nebula# mount -t ntfs /dev/loopa1 /mnt
faith:/nebula# ls /mnt
AUTOEXEC.BAT
boot.ini
CONFIG.SYS
Corel
Documents and Settings
IO.SYS
MSDOS.SYS
NTDETECT.COM
ntldr
PUTTY.RND
Program Files
pagefile.sys
RECYCLER
System Volume Information
WINNT
faith:/nebula# umount /mnt
faith:/nebula# /usr/local/sbin/losetup -d /dev/loopa
faith:/nebula#
By jasonb