Linux Commands – A Quick Reference
// March 12th, 2013 // Infrastructure
In an effort to consolidate into one location notes I’ve made over the years listing common linux commands, I’ve chosen to place them into a single post that will be updated as living reference guide.
I want thank the people that have helped me in compiling this listing either by sharing their own notes, or by pointing me in the right direction when I’ve had questions. (Eric, Kenny, Marcus, Yossef – I mean you guys!).
Linux User and Group Management
Useradds : useradd -g <group> -c "comment" <username> Add the group: groupadd -g <gid> <group> Add from a list: cat asdf | while read a;do useradd -g <gid> $a;done Change passwd from a list : cat asdf |while read a;do echo <passwd> |passwd --stdin $a;done -------- Lock account : usermod -L Change at next login: chage -d 0 <user> Unlock account: usermod -U Modify comment: usermod Password never expires: passwd -x -1 username chage -I -1 -m 0 -M 99999 -E -1 <uid> Add user to additional group: usermod -a -G <group to add> <user>
Linux ACL File Permissions
•• ACL must be set in fstab •• "defaults,acl" getfacl <file or dir> (+ at the end if perms mean ACLs are present) Set user recursive default user perks on dir X: setfacl -Rm d:u:<user>:rwx <file or dir> setfacl -Rm u:<user>:rwx <file / dir> Set user perms on dir X: setfacl -m u:fldtest:rwx <dir> Clear all ACL perms: setfacl -b <dir> Must give x access or it will not work! -d = default going forward -R = recursiave -m = modify Filesystems need to be set to use acl... See mount point in /etc/fstab
RedHat Specific Host Configuration
To Change Hostname or IP to change the hostname/ip it is : /etc/hosts /etc/passwd /etc/sysconfig/network /etc/sysconfig/network-scripts/ifcfg-eth0 To Add New Interface/IP This command will be temporary until the interface startup script is updated: ifconfig eth0 192.168.1.100 netmask 255.255.255.0 up The following configuration files will need to be updated for the interface/IP settings on boot. /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 BOOTPROTO=static DHCPCLASS= HWADDR=00:30:48:56:A6:2E IPADDR=192.168.1.100 NETMASK=255.255.255.0 ONBOOT=yes /etc/sysconfig/network NETWORKING=yes HOSTNAME=www.foo.bar GATEWAY=10.x.x.x Update DNS /etc/resolv.conf nameserver <IP ADDRESS OF NS1> nameserver <IP ADDRESS OF NS2> nameserver <IP ADDRESS OF NS3> Sudoers Update sudoers /etc/sudoers