Linux Walk through
Hola Folks ! Little Things About this CTF from TryHackMe.com .
TryHackMe.com Have Free Room covers most important Commands you must be aware of .Before You Click On Deploy You Should Have Basic Understanding Linux. I Will Only Go Through Some Important Command .
SSH (Secure Shell)
ssh UserName@host .
It is used to access machine remotely. We can use PuTTy (Tool for Window , Linux) for ssh login.
ssh shiba1@Machine ip.
Print Command “Echo”
echo -n hello
Here echo Prints The Value “Hello” . But -n will Show output without a new line.
a = all entries . also hidden files started with .
l = long lists Format
It concatenate files and print on the standard output.
It will create a new text file. touch is used for creating new files.
Running A Binary
For instance, We have a binary file name hello.bn .
./hello = Here ./ used for run the binary file in current directory.
~/hello = Here ~(tilde) used for run binary file in user’s home directory.
../hello = Here ../ is used for run binary file to one above from current directory.
We can switch user to any using command “su”.
e.g. su shiba2 . It will switch user from current to shiba2.
“>” It is used for to save files. e.g. echo shiba2 > test . Here shiba2 will be saved in file test. Remember if you will keep running the command it will keep replacing text everytimes from that file.
“>>” works same as “>” do . But “>>” always appends despite of replacing .
“&&” Command allow you to execute a 2nd command after the 1st one.
“$” is used to denote environment variables.
“echo $HOME” It will print Path of user directory. e.g. /home/shiba2.
“echo $USER” It will print Username.
“export $USER=1111” It will set user equal to 1111
“|” pipe operator allows you to take the output of a command and use it as input for a second command.
cat to get the output of a file, and pipe that into
grep to search for a specific string.
“;” works same as && . But it does not requires to execute first command .
Change mode “chmod”
Used for setting permissions to the users.
1 = Execute
2 = Write
4 = Read
Let’s explain that by setting permissions to them .. For instance
User = Execute , Write , Read (1+2+4)
Group = Read (4)
World = No Permission (0)
So final output will be
chmod 740 filename
Change ownership “chown”
“chown” used for ownership of any. chown is best done with the root(administrator) user.
chown paradox file
“Here we change ownership of file to user named paradox”
Remove Command “rm”
rm can completely destroy your whole Linux system if used carelessly! rm as you might have guessed means remove, and that’s exactly what it does.
Move Command “mv”
“mv” command used for to move a file.
mv <file on current-location> <new-location>
e.g. mv file /tmp
Link command “ln”
One of those is what’s known as “hard linking”, which completely duplicates the file, and links the duplicate to the original copy. Meaning What ever is done to the created link, is also done to the original file.
ln source destination”
e.g. How would I link /home/test/testfile to /tmp/test
ln /home/test/testfile /tmp/test
Find Command “find”
It allows you to do just as it says, find files.
“find /” will search in every directories in OS .
“find dir -user” to list every file owned by a specific user .
find / -user paradox. This will find every file on the system belonging to the user “paradox”
It allows you to find data inside the data .
For instance let’s say you know have the file name of test1234, but you don’t know where it is on the system. find can be used to list every file on the OS, and grep can be used to find the actual file.
find /* | grep test1234
- -n can be included to know the line number.
Adding Users and Groups
In Linux with
addgroup We modify permissions for users and groups. It’s important to note that only root has permissions to add users and groups .
To add a user to a group can be done with the usermod command, the syntax for that is
usermod -a -G <groups seperated by commas> <user>.
E.G. How would I add the user test to the group test ?
sudo usermod -a -G test test.
Important Files and Directories
/etc/passwd — Stores user information — Often used to see all the users on a system
/etc/shadow — Has all the passwords of these users
/home — The directory where all your downloads, documents etc are. — The equivalent on Windows is C:\Users\<user>
/root — The root user’s home directory — The equivilent on Windows is C:\Users\Administrator
/usr — Where all your software is installed
/bin and /sbin — Used for system critical files — DO NOT DELETE
/var — The Linux miscellaneous directory, a myriad of processes store data in /var
$PATH — Stores all the binaries you’re able to run — same as $PATH on Windows
To grep any string from files . e.g. password
grep -l -e “password” -f *