Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
# Below is all the code to do certain things # Note that placeholders are used here and this is a guide! Do NOT use this as a script (it will not work)! # Note also that this is a guide for Bash, so ONLY for Linux (maybe also for MacOS, also based on GNU like Linux) # Basics ## Restart system reboot ## Login as user su userName ### Run code as other user sudo -u userName code_to_execute ## Remove file/directory rm file rm directory ### If the directory not empty rm -r directory ## Copy cp fromHere to ### Copy directory with their subdirectorys and files cp -r fromHere to ## Download files, archives, binarys etc wget url/file.name wget url/archive.name ## Run code as process code_to_execute & # Advanced ## Declare variables variable=example ### Declare variables with code to be executed variable=$(code_to_execute) ## Fetch variable values $variable ### If you want print a value of a variable in a file ${variable} ### For terminal declared variables (rather known as arguments) $1 $2 $3 ## Dedect OS uname ## Dedect kernel uname -r ## Dedect hostname uname -n ## Dedect Processor uname -p ## Dedect Architecture uname -m ## Math ### Greater than if [ 10 -gt 5 ]; then echo "The number is greater than 5" fi ### Smaller than if [ 5 -lt 7 ]; then echo "The number is less than 7" fi ### Equal if [ 5 -eq 5 ]; then echo "The number is equal to 5" fi ## Check for permissions and ownerships ls -lha ## Fetch configured timezone of the system cat /etc/timezone ## Write paragraph content in a file cat << EOF > file.txt ## Content EOF ## Checks the existence of a PID if ( kill -0 PID ); then # Code to execute fi ## Checks for the existence of a specific file if [ -f fileName ]; then # Code to execute fi ## Checks for the existence of a specific directory if [ -d directory ]; then # Code to execute fi ## Checks, if a directory is writable if [ -w directory]; then # Code to execute fi ## Checks, if a file is executeable if [ -x file]; then # Code to execute fi ### You can use this to merge in a one line [ ! -d directory ] && mkdir directory ### To check whether a directory is empty if [[ -z "$(find /pfad/zum/verzeichnis -mindepth 1)" ]]; then echo "The directory is empty" else echo "The directory is not empty" fi ## Use functions (handy when you want to use a whole chain of code multiple times, or simply for the overview) ### Create functions myfunction() { # Code_to_execute } ### Call functions myfunction ## Give the id of the latest runned process echo $! ### Save the id of the latest runned process echo $! > process.pid ## Replace PID journalctl _PID=PID ## Get all user given arguments echo $@ ### Fetch, if a package exists checkPackages() { for cmd in "$@" ; do if command -v "$cmd" ; then $cmd --version return fi done echo "Not found!" } checkPackages thePackage ## Deleting pushed commits in git ### Starting interactive mode git rebase -i ### Delete commit locally git reset HEAD~ ### Delete commit globally (in the repository) git push origin main --force --tags # Experts ## Return the first executing process ps -p 1 -o comm= ### Check, is used systemd or SysV-Init if [ "$(ps -p 1 -o comm=)" == "systemd" ]; then systemctl enable app systemctl start app else service app enable service app start fi ## Set memory swap fallocate -l 4G /swapfile chmod 600 /swapfile mkswap /swapfile swapon /swapfile ## Let's print "!" 10 times c=1 while [[ "$c" -le 10 ]]; do echo -n "!" sleep 1 c=$(($c+1)) done ## Using getops while getopts ":a:b:c:d:" opt; do case ${opt} in a) a=$OPTARG ;; b) b=$OPTARG ;; c) c=$OPTARG ;; d) d=$OPTARG ;; *) echo "Option -$OPTARG requires an argument." 1>&2 exit 1 ;; esac done shift $((OPTIND -1)) echo $a echo $b echo $c echo $d ## Using while with shift while (( "$#" )); do case "$1" in -h | --host) host="$2" shift 2 ;; -p | --port) port="$2" shift 2 ;; -u | --username) username="$2" shift 2 ;; -pass | --password) password="$2" shift 2 ;; *) echo "Unknown parameter passed: $1" exit 1 esac done echo "Host: $host" echo "Port: $port" echo "Username: $username" echo "Password: $password" ## If this error comes: ## Unable to monitor directories for changes because iNotify max watches exceeded, add this to the end of the /etc/sysctl.conf file: fs.inotify.max_user_watches=99999 ### Then run: sudo sysctl -p cat /proc/sys/fs/inotify/max_user_watches ## Generate random strings (also usable as passwords) tr -dc A-Za-z0-9_ < /dev/urandom | head -c 32 | xargs ## Display the IP of the mashine (or computer) ip addr show | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | grep -v '127.0.0.1' | head -1 ## Delete everything in the file file.txt after a : grep -E ".*:.*" file.txt | sed -i 's/:[^:]*//g' file.txt ## Replace test with test2 in example.txt sed -i "s|test|test2|" example.txt ## Check for memory (in KiloByte) awk '/MemTotal/ {print $2}' /proc/meminfo ## Format your echo texts coloured echo -e "\e[31mThis text is red\e[0m" ### All colors #### Black: \e[30m #### Red: \e[31m #### Green: \e[32m #### Yellow: \e[33m #### Blue: \e[34m #### Magenta: \e[35m #### Cyan: \e[36m #### White: \e[37m ### Or getColoured() { tput setaf 1 echo "$@" tput sgr0 } getColoured test #### All colors (Put after "tput setaf") ##### Light red: 1 ##### Green: 2 ##### Yellow: 3 ##### Blue: 4 ##### Purple: 5 ##### Light blue: 6 ##### White: 7 ##### Grey: 8 ##### Red: 9 ## Running code based on selected option options=( "Option 1" "Option 2" # ... ) select opt in "${options[@]}" do case $opt in "Option 1") # Code for option 1 ;; "Option 2") # Code for option 2 ;; # ... esac done
Optional Paste Settings
Category:
None
Cryptocurrency
Cybersecurity
Fixit
Food
Gaming
Haiku
Help
History
Housing
Jokes
Legal
Money
Movies
Music
Pets
Photo
Science
Software
Source Code
Spirit
Sports
Travel
TV
Writing
Tags:
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
⭐Crypto Exchange Profit Method⭐
JavaScript | 1 sec ago | 0.32 KB
Exchange Exploit
JavaScript | 33 sec ago | 0.32 KB
✅ MAKE $500 IN 15 MIN
JavaScript | 42 sec ago | 0.32 KB
ChangeNOW Exploit
JavaScript | 50 sec ago | 0.32 KB
⭐ Instant Profit Method ⭐
JavaScript | 59 sec ago | 0.32 KB
⭐ Free ETH Method ⭐
JavaScript | 1 min ago | 0.32 KB
Free Crypto Method (NEVER SEEN BEFORE)
JavaScript | 1 min ago | 0.32 KB
⭐Crypto Exchange Profit Method⭐
JavaScript | 1 min ago | 0.32 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!