nix alt Flashcards
How to set a password for a user?
passwd [username]
How to lock an account?
usermod -L [username]
How to unlock an account?
usermod -U [username]
Find all PIDS owned by the user?
pgrep -u [username]
list all processes from user?
ps -f f -u username
ps -f –pid $(pgrep -u tecmint)
What files is used to configure how new users are created?
cat /etc/login.defs on redhat systems and cat /etc/deluser.conf on debian systems
Killall processes from user?
killall -9 -u username
Delete user and home files?
Delete user and home files? # deluser --remove-home tecmint [On Debian and its derivatives] # userdel --remove tecmint [On RedHat/CentOS based systems]
(list all the network services and what their default listening ports are
cat /etc/services
check your gateway
netstat -rn
^i think that’s all you need, the verbose flag doesn’t really give you anything extra but maybe it’s good just in case?
netstat -rnv
one way to ssh key
- ssh-keygen (run this on client)
- ssh-copy-id root@192.168.1.1 (copy over your key)
- ssh root@192.168.1.1 (login with no pass)
a. or ssh -l root 192.168.1.1 (same thing, different syntax)
and you can check your stuff on the server by cat /root/.ssh/authorized_keys
(you could’ve manually placed this key in that file too instead of using the ssh-copy-id thing)
What are the commands you would run if you need to find out the version and build date of a package (e.g. http)?
rpm –qi httpd
If you create a new group, which file does it get created in?
/etc/group
To view your command history, which command is used and how to run a specific command?
history and !#
How to create a soft link?
ln –s
How to get information on all the packages installed on the system?
rpm –qa
How to upgrade Linux from 7.3 to 7.4?
yum install update
what are some hardening commands and config files and such?
change default user create settings
cat /etc/default/useradd
cat /etc/login.defs
check running services and adjust stuff you want on/off
netstat -tunlp
turn off root login and other settings for ssh
cat /etc/ssh/sshd_config
setup a firewall
firewalld or iptables
use SELinux
cat /etc/login.defs (change default password settings)
chage -l [username] (check password stuff for user)
cat /etc/shadow
chage (you can use this to change pass settings too)
cat /etc/passwd (see users and if they have shell access and stuff)
??? cat /etc/pam.d/system-auth (something with security?)
systemctl -a (check the services, see if there’s anything you can stop/disable/mask etc)
netstat -tunlp (check what serves are listening and on what ports, then stop/disable the stuff you don’t need)
cat /etc/ssh/sshd_config (change the port that ssh listens on, disable root login, etc. You can go in here and turn off passwordauthentication if you have ssh keys setup - this is a good security thing)
firewall-config (this gives you a gui to disable services, ports, blah blah)
firewall-cmd –help (instructions on how to do the above without a gui)
cat /etc/firewalld/firewalld.conf (configure the basic firewall settings here)
[enable/disable firewalld or iptables and set rules and stuff]
iptables -L (lists iptables rules)
iptables -F (flushes the iptables rules so you have 0)
cat /etc/sysconfig/iptables-config (adjust some iptable settings like how it saves and stuff)
SELinux controls permissions of processes and applications - can’t do this with normie linux
sestatus (checks if SELinux is enabled)
cat /etc/sysconfig/selinux (controls state of SELinux on the system, disable, permit, enforce, etc)
stat [filename] (this gives you the permission details of stuff)
man chcon (change SELinux security context of stuff)
man checkpolicy (selinux policy compliler)
cat /etc/sudoers (you can check this to see who can do root stuffs)
Which 2 files contain default values when creating a user with useradd command?
cat /etc/default/useradd
cat /etc/login.defs
Create a user with a predefined uid, shell, and home directory
useradd -m -d /home/user -s /bin/bash -u 9000 user
Delete a user with his home directory
userdel -r user
Create a user specifying a primary/secondary group
useradd user -g primary -G other groups
Change primary grup for any user
usermod -g primarygroup user
Give sudo access to any user without asking him to privde password everytime he runs a command
user ALL=(ALL) NOPASSWD:ALL
How to check mtu, ip and MAC address?
ifconfig
^this seems to do the same thing. not even sure if -a is a real flag lol what
ifconfig -a
Find running processes on your system
ps -ef
How to view all messages generated by thte system since the last reboot on RHEL7
journalctl
journalctl | grep ssh