TryHackMe Linux Fundamentals Part 2 Walkthrough
Accessing your Linux Machine Using SSH(Deploy):
SSH : It’s the short form of Secure Shell. SSH is a protocol between devices in an encrypted form.
- SSH allows us to remotely execute commands on another device remotely.
- Any data sent between the devices is encrypted when it is sent over a network such as the Internet.
Using SSH to login to a Linux machine:
$ssh username@ip
Above command works if ssh is in port 22. If not…..
$ssh usename@ip -p port
Introduction to Flags and Switches:
Flags and switches are more like options. Most of the Linux commands and tools have flags. If you write a command with -h or — help, you will know which flags and switches it has. Or you can use man. Ex: man nmap
- Explore the manual page of the ls command
Answer: No answer needed.[man ls]
2. What directional arrow key would we use to navigate down the manual page?
Answer: down
3. What flag would we use to display the output in a “human-readable” way?
Answer: -h
Filesystem Interaction Continued:
Some useful commands and their works:
Command Work
---------------- ------------------------------------
touch -------- create a file
mkdir -------- create a folder
cp -------- copy file or folder
mv -------- move file or folder
rm -------- remove file or folder
file -------- determine the type of a file
5. How would you create the file named “newnote”?
Answer: touch newnote
6. On the deployable machine, what is the file type of “unknown1” in “tryhackme’s” home directory?
Answer: ASCII text
7. How would we move the file “myfile” to the directory “myfolder”?
Answer: mv myfile myfolder
8. What are the contents of this file?
Answer: THM{ _______}
Hint: cat myfile
9. Continue to apply your knowledge and practice the commands from this task.
Answer: No answer needed.
Permission 101:
To move a ownership of a file to a different user so that he/she can edit or work on it, we can use chown command.
$chown john /var/file
Here, /var/file is the file we want to change the permission of. john is who we want to move the ownership to.
You can also change the group of a file.
$chgrp hacking file
If you want to see the permissions and owners of files, the command is….
$ls -la
We have 3 types of file permissions.
- Read, r
- write, w
- Execute, x
If you want to change the permissions of files,
$chmod +x file
Here +x is the execute permission. It can be +r or read, +w or write.
You should know how to change permissions of a file with decimal notation.
Binary Octal rwx
000 0 ---
001 1 --x
010 2 -w-
011 3 -wx
100 4 r--
101 5 r-x
110 6 rw-
111 7 rwx
This is binary and octal representations of permissions. Using the above information, If you want to give a file only read permission…
r w x
4 - -
If you want to give a file execute and write permission,
r w x
- 2 1
Add two permissions, 2+1 = 3 which is write and execute permission.
Give all three permissions to a file…
r w x
4 2 1
4+2+1 = 7 that’s all permissions on a file for a user.
In short,
x -- 1
w -- 2
r -- 4
So, if we wanted to represent all permissions for the owner, group, and all users, we could write it as follows:
$chmod 777 file
You should read Linux Basics For Hackers if you want to learn more about Linux basics.
The Differences Between Users and Groups:
Suppose, you are a software engineer. You are the admin of a software. As an admin, you can do anything or visit anywhere in software. But a user can access whatever he/she is permitted to access. A normal user can’t access admin panel or any backend properties.
Switching Between Users:
To switch between users, we use su command.
$su user
10. On the deployable machine, who is the owner of “important”?
Answer: user2
11. What would the command be to switch to the user “user2”?
Answer: su user2
12. Now switch to this user “user2” using the password “user2”
Answer: No answer needed.
13. Output the contents of “important”, what is the flag?
Answer: THM{_____}
Common Directories:
/etc -- This root directory is one of the most important root directories on your system. The etc folder (short for etcetera) is a commonplace location to store system files that are used by your operating system
/var -- This folder stores data that is frequently accessed or written by services or applications running on the system
/root -- the /root folder is actually the home for the "root" system user
/tmp -- Short for "temporary", the /tmp directory is volatile and is used to store data that is only needed to be accessed once or twice
14. Read me!
Answer: No answer needed.
15. What is the directory path that would we expect logs to be stored in?
Answer: /var/log
16. What root directory is similar to how RAM on a computer works?
Answer: /tmp
17. Name the home directory of the root user
Answer: /root
18. Now apply your learning and navigate through these directories on the deployed Linux machine.
Answer: No answer needed.
No comments