---------------------user / group / privilege management -------------------------
view all groups
getent group
add user
useradd ...
add a user to a group
usermod -a -G groupname username
add a group
groupadd ...
delete user
userdel ...
delete user/delete user from agroup
deluser ...
delete a group
groupdel ...
delgroup ...
deluser ...
check the groups of a username
groups username
chmod
u(for owner) g(for group) ofor(others) a(for all, ie ugo)
+ (add permission) - (remove permission) = (assign permission absolutely)
r (read) w(write) x(execute)
so, chmod ug +w-x /folder/
means add write permission to u and g, and remove exeucte permission from u and g
another example, chmod go +r /folder/
means add read access to g and o
change ownership of a folder
chown ...
-------------------------text manipulation--------------------------
cut
extract sections from each line of files
it can cut by character, byte position, delimiter and pattern
cut by byte position
echo 'abc' | cut -b 2 returns b
cut by character position
echo 'abcd' | cut -c 2-3 returns bc
cut by delimiter
assuming there is test.csv file as follows:
a,1
b,2
c,3
then
cut -d ',' -f 1 test.csv
returns
a
b
c
the -d specifies the delimiter, the -f specifies the field to extract