Linux Commands Examples

A great documentation place for Linux commands

ownership

Compaq ownership tag retriever


see also : biosdecode - dmidecode - vpddecode

Synopsis

ownership [OPTIONS]


add an example, a script, a trick and tips

: email address (won't be displayed)
: name

Step 2

Thanks for this example ! - It will be moderated and published shortly.

Feel free to post other examples
Oops ! There is a tiny cockup. A damn 404 cockup. Please contact the loosy team who maintains and develops this wonderful site by clicking in the mighty feedback button on the side of the page. Say what happened. Thanks!

examples

0
source

How to make a file editable by two different users in different groups?

Rather than modify permissions on the directory, it might be easier to put the user john into the www group. Users can be in multiple groups. Use either usermod, edit the /etc/group file, or if you have a GUI on your linux machine use the graphical user manager program (might be called different names based upon distro and desktop environment). The easiest method is probably to open a command prompt, and type in:

sudo usermod -G www -a john

It'll ask for your account password, and once you enter it, the user john will be have group level access to the /home/www directory.

This is assuming the group www already has read/write/execute access to the /home/www directory If that group doesn't have that level of access then use chgrp www /home/www and chmod g+rwx /home/www to take care of that.

note: if you are currently logged in as 'john', you may need to log out and back in for your permissions to update.

0
source

Restrict device ownership to root only. But why?

Device file ownership means exactly the same thing as ownership of any file; the user owner is allowed access via the user permission bits (e.g. -rwx------) and can change the permissions of the file, the group owner via the group permission bits (e.g. ----rwx---), and everyone else via the "others" permission bits (e.g. -------rwx).

You restrict ownership to root so that if a non-root process has been compromised the perpetrator can't access the device file or change its permission bits, thereby reducing the security risk present.

0
source

shell script - How to output the owner of a file

I would use that function:

lso() { ls -dl ${1:?usage: lso file} | awk '{print $3;exit}'; }

Edit:

  • I thought about stat but I try to avoid using anything non standard when possible. I sticked with something portable (i.e. POSIX) as your question is tagged linux and unix, not just linux with which stat is quite standard..

  • As this question triggered a discussion about valid usernames, these are also defined by a Unix standard to be a string composed exclusively of characters from this list:

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

a b c d e f g h i j k l m n o p q r s t u v w x y z

0 1 2 3 4 5 6 7 8 9 . _ -

with the additional restriction for the hyphen not to be the first character.

I assumed no space was allowed. Just like anything else which is non-portable this can lead to unexpected results not only with my small function but with many Unix/Linux CLI utilities.

0
source

When I create files the owner / group is always root

You can't resolve it; the system is behaving as expected. The sudoers file controls the sudo command, it does not change the way the kernel interprets file and directory permissions. In order to get the effects of sudo, you must run sudo. What sudo does is run commands as root, so naturally files created by a sudo-run command are owned by root.

0
source

What privilege is required to preserve ownership of a file on copy, and how do you get it?

See the capabilities(7) manual page – you need the CAP_CHOWN capability to change file ownership via chown(). (Root has all capabilities enabled automatically. The manual page explains how to obtain capabilities in other cases.)

There is no separate method/capability to just preserve ownership, as Linux file copies are made by simply reading/writing data to the destination file, then doing the same with metadata. (For comparison, Windows NT has SeBackupPrivilege and SeRestorePrivilege privileges and the BackupRead()/BackupWrite() calls.)

0
source

Have sudo create files under your own user id?

You can use tee. What tee does is write stdin to a file and echo it on stdout too. Using it with a pipe and sudo effectively changes the active user for output redirection. Bear in mind that the left side of the pipe must actually write to stdout, not stderr.

sudo fdisk -l | sudo -u myuser tee <file>
0
source

changing the ownership of a file in linux

Yes, you can add o+r, meaning, others can read:

chmod o+r test
0
source

Why user becomes nobody?

User alias

A possible explanation is that you already had a user called nobody with the UID (User ID) 532. The result is you have created a "user alias".

You either can try to specify another UID for your user (or let the system pick-up one). Or you can leave it like that. The only security risk is that if a service or other user can access nobody's data then it will be able to access your data.

NFS User ID Mapping

For users to have the feeling they are accessing their own files, the UID on the NFS server should match the UID on the NFS clients. Although, you want to avoid that for root at least.

By default, NFS exportfs will choose UID/GID of 65534 which corresponds to your user nobody's UID. You need to instruct the NFS server not to map all UID to 65534 or if this is the wanted behaviour, you need to specify the mapped default UID.

For the first case, remove the all_squash and replace it by root_squash, but bare in mind that any non root user with a similar UID between the NFS server and any clients will be a match, so they own the files"

For the second case, keep the all_squash but add anonuid=532 (you can use also anongid for the GID (or Group ID)).

Example:

/               pc001(rw,root_squash)
/home/joe       pc002(rw,all_squash,anonuid=532,anongid=100)

Note: the changes should be done in the file /etc/exports on the NFS server.

0
source

Always have to chown when adding new file? Centos 6

Most likely, what is actually needed for the files to be accessible is that their group is set to apache. You can easily set it by default for new created files by running :

find /path/to/root/directory/of/website -type d -print0 | xargs -0 chmod g+s

This will set the setgid flag on all sub-directories too. With this flag set, any new file created in there will inherit the group of its parent directory. (-print0 and -0 options are designed to handle correctly spaces in filenames)

Make sure ownerships of files are correct before running it. If unsure, you can fix it the same way :

find /path/to/root/directory/of/website -print0 | xargs -0 chown apache:apache
0
source

Avoid errors from tar failing to restore directory permissions

This tar option might be what you're looking for:

 --no-overwrite-dir
       preserve metadata of existing directories

I tested as follows:

$ mkdir a b a/diffowner
$ sudo mkdir b/diffowner
$ sudo chmod a+w b/diffowner
$ echo foo > a/diffowner/foo
$ tar -C a -cvf test.tar diffowner
diffowner/
diffowner/foo
$ tar -C b --no-overwrite-dir -xvf test.tar diffowner
diffowner/
diffowner/foo
$ echo $?
0

description

ownership retrieves and prints the "ownership tag" that can be set on Compaq computers. Contrary to all other programs of the dmidecode package, ownership doesn’t print any version information, nor labels, but only the raw ownership tag. This should help its integration in scripts.

options

-d, --dev-mem FILE

Read memory from device FILE (default: /dev/mem)

-h, --help

Display usage information and exit

-V, --version

Display the version and exit

files

/dev/mem


see also

biosdecode , dmidecode , mem, vpddecode


author

Jean Delvare

How can this site be more helpful to YOU ?


give  feedback