Automating VLAN Creation on Cisco Devices with Ansible

Linux provides a variety of commands to retrieve information about system users, directories, and processes. This article presents 20 essential Linux commands for listing and managing users, folders, and processes, applicable to both Ubuntu and Red Hat systems.
cat /etc/passwd
Displays a list of all users on the system along with their user IDs, home directories, and shells.
getent passwd
Fetches user information from the system's databases, useful in environments with LDAP or NIS.
who
Shows all users currently logged in to the system.
w
Displays detailed information about logged-in users, including their active processes.
users
A simple command that lists the currently logged-in users.
id [username]
Displays user ID (UID), group ID (GID), and group memberships for a specific user.
finger [username]
Provides information about a user, including their real name, login time, and more. (May require installation: sudo apt install finger
on Ubuntu, or sudo yum install finger
on Red Hat).
ls
Lists files and directories in the current folder. Add options like -l
(long format) and -a
(hidden files) for more details.
Example: ls -la
.
tree
Displays directories and their contents in a tree-like structure. (Install using sudo apt install tree
or sudo yum install tree
).
find /path/to/search -type d
Finds and lists all directories under a specified path.
Example: find /home -type d
.
du -h --max-depth=1
Shows the size of directories in the current location, useful for identifying large folders.
df -h
Displays disk usage for mounted file systems, including directories.
stat [filename]
Provides detailed information about a file or directory, such as size, permissions, and last modification time.
lsblk
Lists all block devices and their associated mount points, useful for identifying file systems.
ps aux
Displays all running processes, including user information, CPU usage, memory usage, and more.
top
Provides a real-time view of running processes and system resource usage.
htop
An interactive process viewer similar to top
but with more features. (Install using sudo apt install htop
or sudo yum install htop
).
pidof [process_name]
Returns the Process ID (PID) of a specified process.
Example: pidof apache2
.
pgrep [process_name]
Searches for processes based on their names and displays their PIDs.
Example: pgrep sshd
.
kill -l
Lists all available signals you can send to processes. Combine this with kill [PID]
to terminate or manage processes.
cat /etc/passwd | cut -d: -f1
ps -u [username]
find /path/to/search -type f -size +100M
netstat -tulnp | grep [port_number]
These commands offer powerful ways to manage and monitor your Linux system. Whether you're an administrator or a curious user, mastering them will significantly enhance your Linux skills. Ubuntu and Red Hat both support these commands, ensuring versatility across distributions.
Do you have a favorite Linux command? Share it below!
Comments