Tag Info

Hot answers tagged

24

Using the octal codes has two advantages I can think of, neither of which is that huge: They're shorter, easier to type. A few things only understand them, and if you routinely use them you'll not be scratching your head (or running to documentation) when you run into one. E.g., you have to use octal for chmod in Perl or C. Sometimes really simple ...


15

Problems? Yes, lots. Can it be fixed? Sure. Faster than reinstalling? Probably not. My recommendation is to reinstall. Keep a backup of the existing system, and restore the package list and the contents of files in /etc and /var. For /usr/local, you can probably restore permissions manually. For /home and /srv, you'll have to restore the permissions from ...


14

There is -strictly speaking- no such thing in UNIX as "conflicting permissions": access permissions on an filesystem entry (directory, file, etc.) determine what you can or can not do on that object. Permissions on other filesystem entries do not enter into the picture, with the exception of the "x" bit on all ancestors directories in the path to a file ...


12

Please note that chmod 777 filename is the equivalent of chmod 0777 filename in this example. The first octal digit sets the setuid, setgid and sticky bits (see this article for more details on setuid/setgid). octal 2 means to set group ID on the file. So, the equivalent would be to do a chmod a+rwx filename, then chmod g+s filename. The chmod info page ...


12

Make sure that your mount options allow the execute permission bit. There are mount options one can use to limit the permissions of files within the mounted filesystem: general noexec prevents all files from being executable, FAT-specific option showexec grants the permission only to files with extensions .exe, .com and .bat. Note also that noexec is ...


10

You may not notice it at first, but lots of things can and will go wrong. The main problem is that the entire security model for the entire system is broken. It's like having a body without a skin, organs all out in the air. It's bound to get infected because it's not meant to function like that. Even if it seems to work for a few minutes, you need to clean ...


10

You can use find. find ./ -type d -execdir chmod 750 {} + Where 750 is the mode you'd like to apply and "./" is the directory you will recursively search. EDIT: Thanks to @Gilles and find(1), I've revised this for additional security and performance.


9

There's no magic bullet here. The permissions carry information which is not always redundant. If you'd done this in a system directory, your system would be in a very bad state, because you'd have to worry about setuid and setgid bits, and about files that are not supposed to be world-readable, and about files that are supposed to be group- or ...


9

You need to have the execute bit set on a directory to allow the affected user to enter it and access files and directories inside, and you've removed it (your command removes the execute bit from both the files and the folders). There is information about this here. The following command should fix it: find ~/Documents -type d -exec chmod a+x {} +


9

If you don't want to remove the executable bit from existing files you can use the X mode. To recursively set the executable bit on all directories use: chmod -R a+X dir From man chmod: execute/search only if the file is a directory or already has execute permission for some user (X)


8

Here's a script you can call by passing the mode as the first argument and one or more directory names as subsequent arguments. Under Linux, if you don't pass any directory name, it'll be as though you passed . (the current directory). Name this script rchmodf, make it executable (chmod a+rx /path/to/rchmodf) and put it somewhere on your $PATH. #!/bin/sh ...


8

The permissions passed as an argument to chmod are specified as an octal value. Each numeral in the value represents three bits. If three numerals are given, you're setting the read, write and execute bits for the file's owner, group and others (everyone else). If four numerals are given, the leftmost number sets the setuid, setgid and sticky bits. Octal ...


7

You specified the s bit for the group without the x bit. Executable and setgid are separate bits, the ls command just combines them into a single letter to gain space. You need chmod g=rwxs,u=rwx,o=rx folder_name i.e. chmod 2775 folder_name. You did chmod 2765 folder_name. S means setxid without executable, it's in uppercase because that's rarely useful ...


7

It is not a bug, it's a featureTM (Also, just a consequence of universal unix approach to permisions). Apart from dropbox-like behavior in case of directories (as described by BillThor), write-only access is necessary for some special (pseudo-) files under /proc and /sys. Such files are used to set some driver or kernel properties or trigger a system ...


7

Making symlinks to binaries is fine; check /bin and /usr/bin and you'll almost certainly find a number of aliases. The problem here is using sudo without fully understanding the consequences. Fortunately there was no permanent harm and you learned an important lesson. When you're just making sure they're executable, use a+x or even u+x instead. As uther ...


7

Please check stat output: # stat .xsession-errors File: ‘.xsession-errors’ Size: 839123 Blocks: 1648 IO Block: 4096 regular file Device: 816h/2070d Inode: 3539028 Links: 1 Access: (0600/-rw-------) Uid: ( 1000/ lik) Gid: ( 1000/ lik) Access: 2012-05-30 23:11:48.053999289 +0300 Modify: 2012-05-31 07:53:26.912690288 ...


6

The simplest way I can think of is simply creating a new user partyuser, and assigning it read permissions to a 'public' music directory. To make the music directory (with it's subdirectories and files) to become readable by others you run: # chmod -R r+o /path/to/music_dir That way this user can not list or access files in your own user's home directory ...


6

I have never seen +a, only something like chmod a+r which means "add read permissions to all users" (owner/user, group, others). From man 1 chmod: The format of a symbolic mode is [ugoa...][[+-=][perms...]...], where perms is either zero or more letters from the set rwxXst, or a single letter from the set ugo. Multiple symbolic modes can be given, ...


6

You forgot the "change what" part of the command. Most commands are like a simple "verb-noun" type structure. (Which, if you think about it, tends to explain why we sound like Yoda when we talk) You said "chmod 755"... which is the verb... where's the noun? sudo chmod 755 . # the '.' means 'here' -or- sudo chmod 755 /opt # always better to ...


6

That depends on how you define which files should be set as executables. For example, if consider all the files that do not have dot in filename, you can use: find -type f -not -name "*.*" -exec chmod +x \{\} \; This will find recursively all the files (not directories) that do not have dot in file name and set them executable. If you want to limit this ...


6

This is a typical behaviour of a filesystem that doesn't understand access permissions - very likely a (V)FAT partition. This is also indicated by the path /media/..., which is where removable media is mounted nowadays. The permission problem occurring when trying to run the script could be caused by the noexec mount option (which is understandable ...


6

You can ask GNU stat to output the permissions in octal format by using the -c option. From man stat: -c --format=FORMAT use the specified FORMAT instead of the default; output a newline after each use of FORMAT ⋮ %a access rights in octal ⋮ %n file name So in your case: bash-4.2$ ls -l foo ...


5

The better solution should be chmod -R ug=rwX,o=rX /path where the capital X means: set execute bit if the file is a directory or already has execute permission for some user (quoted from chmod man page). Or also, if you want to use find find /path \( -type f -exec chmod ug=rw,o=r {} + \) -o \ \( -type d -exec chmod ug=rwx,o=rx {} + ...


5

It's all a method of granting various access to a file. User is an individual user. Use this when you want to give one person and only one person access. Group is more than one user. Use this when you want to give several people access. Put them all in a unique group and set that as the group owner. Other is for anybody who isn't the user or group owner. A ...


5

Why do you need octal number in the first place? I always use: chmod o+x file # all + eXecute permissions chmod g-w file # group - write perms chmod u=r file # user can just read chmod ug=rw file # user,group = read and write chmod a+w file # user,group,others + write ugo(a) is easy to remember. However you can confuse o:=owner? o:=other? but ...


5

Short answer: No. The tar utility is made specially for archiving directory structures under unix-like systems. It preserves all the ownership and permission information of the files/directories included¹. Regardless of the user running the tar command. At least this is case of standard invocation. But I presume that if you were to exercise any advanced ...


5

If the user extracting is a "ordinary" user, the files will be owned by that user (by default). From the manual page of tar --same-owner try extracting files with the same ownership as exists in the archive (default for superuser) --no-same-owner extract files as yourself (default for ordinary users)


5

Unix permissions don't apply to and can't be mapped to Windows permissions, so chmod is necessarily a no-op. (FAT doesn't have permissions at that granularity, and NTFS permissions are stored not by username or numeric ID but by a UUID that Linux has no access to.) The permissions you see are manufactured by the umask=002 part of the mount options.


5

The full permissions mode number is a 4-digit octal number, though most of the time, you only use the 3 least-significant digits. Add up each group in the permissions string, taking r=4, w=2, x=1. For example: 421421421 -rwxr-xr-- \_/ -- r+w+x = 4+2+1 = 7 \_/ -- r+_+x = 4+0+1 = 5 \_/ -- r+_+_ = 4+0+0 = 4 => 0754 Now, ...


5

I don't recall where I found this, but I use the following in my ~/.vimrc " Set scripts to be executable from the shell au BufWritePost * if getline(1) =~ "^#!" | if getline(1) =~ "/bin/" | silent !chmod +x <afile> | endif | endif The command automatically sets the executable bit if the first line starts with "#!" or contains "/bin/".



Only top voted, non community-wiki answers of a minimum length are eligible