Skip to content

Instantly share code, notes, and snippets.

View howtouselinux's full-sized avatar

howtouselinux howtouselinux

View GitHub Profile
---
- 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
@howtouselinux
howtouselinux / linux-commands-cheat-sheet.md
Created December 23, 2022 12:42
Linux commands cheat sheet

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
@howtouselinux
howtouselinux / check-ip-address-in-Linux.md
Created December 23, 2022 08:12
how to check ip address in Linux

du

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

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/somedir

reference: how to check file creation time in Linux

Output

Below, you'll find a collection of Linux resources categorized into resource types - videos, books, sites, etc. I hope it will serve you well in your journey of becoming a Linux Master ;

Learn Linux Sites for Beginners

@howtouselinux
howtouselinux / linux-users.md
Created December 18, 2022 07:40
How to manage users and groups in Linux

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

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

@howtouselinux
howtouselinux / interview.md
Last active December 18, 2022 04:13
top 15 Linux interview questions and answers

Top 15 Linux Interview Questions & Answers for Job Seekers

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.

Top 15 LINUX Interview Questions And Answers