lazyhacker 9 months ago
Illusion #linux

Make your python scripts accessible anywhere in your Linux terminal

Lately, I've been endeavouring to automate some of the basic and mundane tasks I regularly perform on my computer. One task that I aim to automate is the ability to open any of my popular social media platforms (Instagram, Facebook, WhatsApp) with a simple command in the terminal.


After finding the solution to the problem, I encountered another issue: I had to navigate to the script's directory every time I wanted to use it. This process was not only cumbersome but also undermined the automation I sought. Determined to resolve this, I conducted some research online, and here are the steps I followed to make my script globally accessible in the terminal:


First, find the path to the interpreter you are using by typing the following into a terminal:

$ which python3

Next, add the following line at the top of the script file:

#! /usr/bin/python3

(Note: This should be the path to the interpreter displayed by the command in the first step.)

Change your script's permissions with:

chmod u+x socials.py

Now, move your script to the following directory. You need administrator privileges to do this. Type the following command (replace `<directory>` with the desired location):

sudo mv socials.py /usr/local/bin/<directory>/socialscamelCasesnake_case

(Note: You have to remove the file extension if the file has one, and change it to a suitable name using camelCase or snake_case.)

Alternatively, you can create a link to the script without moving the file using the following command:

sudo ln -s /path/to/socials.py /usr/local/bin/socials

References:

1. Linux custom executables are available globally.

2. How to make a globally available executable script in the scripting language of your choice.

0
526
Installing Kali Linux on Android without Root

Installing Kali Linux on Android without Root

defaultuser.png
Admin
3 months ago

White box testing

https://lh3.googleusercontent.com/a/ACg8ocIkM8EGIx0gz9GUP_nM6_sMxivr6876Wp0e9MAp6mGc=s96-c
xone
3 weeks ago
one-line web server

one-line web server

defaultuser.png
lazyhacker
9 months ago
Metasploit

Metasploit

defaultuser.png
Admin
3 months ago
Awkward HTB Writeup | HacktheBox

Awkward HTB Writeup | HacktheBox

https://lh3.googleusercontent.com/a/ACg8ocIkM8EGIx0gz9GUP_nM6_sMxivr6876Wp0e9MAp6mGc=s96-c
xone
1 month ago