Sometimes we don't want to change our umask setting but want to give a certain user the read-write permissions to some files or directories. We can do that by using Linux's ACL (Access Control List) commands setfacl and getfacl. Manpages of these commands give the full usage and explanation. The following are some examples.
For instance, user1 has a directory named shared_dir. user1 wants the files generated in shared_dir can be read-written by both himself and user2. He can run these commands:
$ setfacl -d -m u:user1:rw shared_dir
$ setfacl -d -m u:user2:rw shared_dir
The -d option make the operations apply to the Default ACL. The Default ACLs can only be applied to directories. They determine the permissions a file system object inherits from its parent directory when it is created.
If user1 wants to allow a certain group group1 to have read-write permissions on the files in shared_dir, he can use this command instead:
$ setfacl -d -m g:group1:rw shared_dir
After running setfacl to change the ACL, you can use getfacl to check the result.
Sunday, May 5, 2013
Wednesday, May 1, 2013
Linux tips: making a patch, core dump file
Tip 1: making a patch
To create a patch:
$ diff -u original-file updated-file > patch-file
To appliy a patch:
$ patch original-file patch-file
Tip 2: enable core dump file
In some system, core dump file can not be generated by default. When you run command
$ ulimit -a
or
$ ulimit -c
You can see your max core file size is set as 0, which prevent a dumping of the core file. To enable core dump, you will want to run
$ ulimit -c unlimited
to allow core files to be generated.
To create a patch:
$ diff -u original-file updated-file > patch-file
To appliy a patch:
$ patch original-file patch-file
Tip 2: enable core dump file
In some system, core dump file can not be generated by default. When you run command
$ ulimit -a
or
$ ulimit -c
You can see your max core file size is set as 0, which prevent a dumping of the core file. To enable core dump, you will want to run
$ ulimit -c unlimited
to allow core files to be generated.
Saturday, April 13, 2013
Change the value of a std::string in gdb debugging
In gdb stepping, you can change the value of a variable by running:
(gdb) set myvar=5
to change the variable myvar to 5.
Because an std::string is not a primitive data type, it cannot be changed in this way.
The std::string is a class and it has methods that you can call in gdb to change the value of an instance of it. For example, if mystring is an object of std::string, you can do either:
(gdb) call mystring.assign("new value")
or
(gdb) call mystring.operator=("new value")
to change the value of mystring into "new value".
(gdb) set myvar=5
to change the variable myvar to 5.
Because an std::string is not a primitive data type, it cannot be changed in this way.
The std::string is a class and it has methods that you can call in gdb to change the value of an instance of it. For example, if mystring is an object of std::string, you can do either:
(gdb) call mystring.assign("new value")
or
(gdb) call mystring.operator=("new value")
to change the value of mystring into "new value".
Subscribe to:
Posts (Atom)