Reference: Linux commands cheat sheet
#Linux Cheat Sheet
##File Commands:
- ls – directory listing
- ls -al – formatted listing with hidden files
- cd dir - change directory to dir
- cd – change to home
- pwd – show current directory
| --- | |
| - name: Define a Simple Dictionary | |
| hosts: localhost | |
| gather_facts: no | |
| vars: | |
| my_dict: | |
| key1: value1 | |
| key2: value2 | |
| key3: value3 | |
| tasks: |
| --- | |
| - name: Check if Variable is a Dictionary | |
| hosts: localhost | |
| gather_facts: no | |
| vars: | |
| var1: | |
| key1: value1 | |
| key2: value2 | |
| var2: "Not a dictionary" | |
| tasks: |
| --- | |
| - name: Configure Users | |
| hosts: localhost | |
| gather_facts: no | |
| tasks: | |
| - name: Create dictionary of users | |
| set_fact: | |
| users: | |
| user1: | |
| name: jdoe |
Reference: Linux commands cheat sheet
#Linux Cheat Sheet
##File Commands:
Reference: 3 Easy Ways to Find IP address in Linux
Find private ip address for all network interfaces in Linux
ip a
ip addr
ip address show
ifconfig -a
Summarize disk usage of each FILE, recursively for directories sorted by size
sudo du -x -h / | sort -n | tail -40
reference: how to check file size in Linux
Truncate files to size 0MB
truncate -s 0 production.log
Apparently the stat utility only shows the creation time for files but leaves out the birth field empty for directories.
stat /path/somedirreference: how to check file creation time in Linux
Output
In every operating system, there are users and groups with unique names and unique IDs. These users have access, control and permissions to create and manipulate files, manage processes and services.
In linux, there are four types of users: use the $ cat /etc/groups to view all the users and user groups or $ sudo cat /etc/passwd to view the users and users groups in detail including the paths(directory) where their files are stored.
Root user is a default user automatically created upon the OS installation. The root user has the highest privileges, access to all files and services and can perform a wide range of functions. The default ID for every root user is 0. One of the ways to perform functions with administrative privileges is to initiate a command using $ sudo which means superuser do . You can equally enter into root with $ sudo -i. However, you need to provide the root password for authentication. Run $ sudo cat /etc/sudoers to view users
Do you know that more than 90% of the fastest computers in the world run on Linux? Linux is fast, strong, and a favourite among techies. If you want to become a Linux Administrator, this is the right place to prepare for the interview.
In this article, we have shared the 15 top Linux interview questions and answers that every job seeker should read.