Linux Flashcards
How to check the kernel version of a Linux system?
Uname -a
How to see the current IP address on Linux?
Ip a
How to check for free disk space in Linux?
df -ah
How to see if a Linux service is running?
Service –status-all
Service
How to check the size of a directory in Linux?
Du -sh foldername
How to check for open ports in Linux?
Netstat -tulpn
ON REMOTE HOST
telnet 8.8.8.8 53
nc -w5 -z -v (AKA NETCAT)
How to check Linux process information (CPU usage, memory, user information, etc.)?
Ps aux
Top
htop
How to deal with mounts in Linux
mount
what does LSOF return
the list of open files COMMAND PID TID TASKCMD USER FD (file descriptor) TYPE DEVICE SIZE NODE NAME
Difference b/t CTRL-C and CTRL-Z in linux
CTRL - C sends SIGINT which interrupts the application, usually cause process abort and give you a blank prompt
CTRL - Z send SIGSTP which sends the application to suspend mode on the backend to be continued later with fg
Difference between Tar and ZIP
tar is only an archiver while zip archives and compresses.
tar preserves setuid, setgid, and sticky bit
SETUID
Setuid is a Linux file permission setting that allows a USER to execute that file or program with the permission of the owner of that file. This is primarily used to elevate the privileges of the current user.
SETGUID
Setuid is a Linux file permission setting that allows a USER to execute that file or program with the permission of the owner of that file. This is primarily used to elevate the privileges of the current user.
Same as SETUID except with GROUPS
STICKY BIT
Prevents everyone except the OWNER of a directory from deleting a file…like on tmp folders.
How to check open ports on a remote server without NET CAT or NMAP
echo > /dev/tcp// && echo “GOOD” || “BAD”
5 ways to secure an SSH connection.
Disable Password Based Logins and Allow Key based logins
Disable root login
Change the standard port number
Force the service to use only SSH v2
White List users or servers “Allowed List” is the new PC term.
LVM
Logical Volume Manager
LV-extend / LV-reduce to extend or reduce partition sizes
create/resize/delete LVM partitions while the server is running.
How would you connect to a machine in the cloud
Is there a VPN…connect to it.
SSH @
CD
change directory
CD /
LS
list directory contents.
ls [flags] [directory]
PWD
print working directory (path of current directory or the one you choose)
echo
Displays a line of txt
grep
print lines to match patterns
If no FILE is given, recursive searches examine the working directory, and nonrecursive searches read standard
input.
cp
Copy file
cp
systemctl
Control the systemd system and service manager
How to list services with systemctl
systemctl list-units type=service
how to get status of a service
systemctl status
how do you enable a service to start at boot time
systemctl enable
start or stop a service
systemctl start/stop
What is init system.
o Init is the first process o Starts all services and units o Reparening orphaned processes o Systemctl enable/start services o Journalctl -fu nginx (logs)
How do you show ip address of eth0
• Ip addr show dev eth0
how to you display route information
ip route show
Know the basics of System D
Contains Init which boots the rest of the system Collection of programs and libraries systemctl and journalctl init process management network management login management logs etc
What is a linux user made of?
Bascially a bunch of lines in a bunch of different files
Passwd gives username UID password or reference to the hashed password file
remove user from all groups before deleting
What do you know about PROC?
Proc file system (procfs) is virtual file system created on fly when system boots and is dissolved at time of system shut down.
It contains useful information about the processes that are currently running, it is regarded as control and information center for kernel.
How can you check resource utilization
top, htop, or atop
How do you look for application binary?
whereis will show you where the app and man pages live