Intelligence is simply talking to many people

Linux Commands

In Terminal:

REGULAR COMMANDS

  • paste: ctrl-shift-v
  • check disk space: df -h
  • check What is computer (64 or 32): uname -a
  • check What distro is on computer: lsb_release -a
  • view image metadata (with imagemagick):
  • sudo -i to become root (also sudo su?)
  • ls - list
  • cd D and double-tab and it will show you options starting with D
  • echo “Hi!” > text.txt
  • cp text.txt Downloads - move this file to Downloads
  • rm Downloads/test.txt - remove that file
  • mv test.txt Downloads/ - physically move it
  • cd .. cd .. locate bash but it doesn't find anything, so
  • updatedb then try again
  • passwd - to change a password
  • man ls AND ls --help give some info about the command. man is manual.
  • pwd - present working directory
  • cd / - to go to root
  • Execute several commands https://stackoverflow.com/questions/13077241/execute-combine-multiple-linux-commands-in-one-line:
  • && to execute ONLY if previous command succeeded
  • ; to execute even if previous doesn't succeed
  • You can also write a shell script
  • See list of Timezones with timedatectl list-timezones
  • Upgrade a single package/program only with apt-get install --only-upgrade

usr does not mean user, it means universal system repository (or something).


INTERESTING COMMANDS

  • killall programName ... kills that process (which you might have seen using lots of resources in Terminal)
  • identify -verbose filename.png

GET INFORMATION ABOUT COMPUTER, COMMANDS

  • Find out which desktop environment (DE, for example MATE) you are using: echo $XDG_CURRENT_DESKTOP
  • top: shows RAM usage
  • lsmem: shows how much RAM you have
  • lscpu shows computer specs
  • cat /proc/cpuinfo shows even more specs
  • free -m shows free available RAM details
  • cat /proc/meminfo also
  • sblk shows available disk space
  • df -h
  • sudo dmidecode -t system
  • sudo dmidecode -t bios
  • sudo dmidecode -t processor ... these show BIOS info
  • sudo dmidecode -q will show ALL system info, but a lot
  • more commands for seeing linux sysem info: https://www.how2shout.com/linux/linux-system-info-commands-using-terminal/
  • echo $XDG_SESSION_TYPE .... Check if you're using Wayland or X11.

USEFUL COMMANDS

  • How to install .sh scripts
  • sh install.sh
  • might have to:
  • chmod +x /path/to/yourscript.sh
  • list connected devices and sd cards with: lsusb or lsblk
  • Rotate screen: xrandr -o left
  • Return to normal screen rotation with: xrandr -o normal
  • Check if you have an app, and which version it is with: applicationname -v, for example pdftoppm -v

** DISABLE TOUCH SCREEN **

  • install xinput
  • type ‘xinput’
  • you'll see a list. Find the one that is your screen/finger/digitizer and do
  • xinput disable 9 (as long as the id is 9)

YouTube-dl (outdated)

* download mp3 (using youtube-dl): 

youtube-dl -x --audio-format mp3 http:address

* download playlist as mp3s: 

youtube-dl --ignore-errors --format bestaudio --extract-audio --audio-format mp3 --audio-quality 160K --output "%(title)s.%(ext)s" --yes-playlist https:address ```


LINUX FOR ETHICAL HACKERS (YouTube course)

chmod +rwx

or just

chmod +x

or

chmod 777 hello.txt

adduser john

cat /etc/passwd

(you will see john at bottom)

cat /etc/shadow

(you can only see hashing format - a tool like hashcat can break that down and crack passwords)

...

(su is switch user)

su john

passwd root (to change root's password, but this does not work. Neither does)

sudo passwd root

(because john is not in the sudoers file)

...

userdel john

(deletes john)

networking terms - brush up for pentesting. You'll have to navigate around networks.

ifconfig (shows different interface types and IP address associated with them)

iwconfig (only usually see if using a laptop)

ping (icmp traffic)

arp -a (show you IP address it talks to and mac address tied to it)

netstat -ano (you can see what's talking) (what that machine is associated with and if it's talking on a port)

route (print your routing table) (tells you where your traffic exits, essentially)

102:00


bulk renaming with Thunar.

Use ‘Numbering’ and do ‘Text - Number’ and add your text there too.


Make a txt file: https://www.youtube.com/watch?v=T20jXu7rDCA

Nano way:

  • cd to whatvr dir
  • touch filename.txt
  • (now, ls -l will show you have that file but no size)
  • (can see contents of file with ‘cat filename.txt’)
  • (nano by itself opens the text editor n you can tipe)
  • (ctrl-shft-V does paste)
  • Ctrl-O saves the file

  • cd to directory

  • ls to check it
  • cat > filename.txt [enter]
  • type text and then [CTRL-D to save]
  • ls to check it's there
  • cat filename.txt to read it

OR

  • touch filename.txt [enter]
  • ls to see it

WAV to MP3

  • batch convert all the files in a folder from wav to mp3 using ffmpeg
  • for i in Silver0709.wav; do ffmpeg -i "$i" "${i%.*}.mp3"; done

Get Mono sound out of speakers

  • pacmd list-sinks | grep name:
  • then
  • pacmd load-module module-remap-sink sink_name=mono master=NAME_OF_AUDIO_SINK_GIVEN_BY_PREVIOUS_COMMAND_BUT_WITHOUT_ARROW_BRACKETS channels=2 channel_map=mono,mono
  • Then if you click on your sound icon, you should have an option for ‘Remapped Built-in etc’

Convert a bunch of images into a video using ffmpeg, MP4

  • ffmpeg -loop 1 -i easywords1.jpg -i easywords1.wav -vf "crop=trunc(iw/2)2:trunc(ih/2)2" -c:v libx264 -tune stillimage -c:a aac -b:a 192k -pix_fmt yuv420p -t 1480 out-image.mp4
  • ffmpeg -loop 1 -i easywords2.png -i easywords2.wav -vf "crop=trunc(iw/2)2:trunc(ih/2)2" -c:v libx264 -tune stillimage -c:a aac -b:a 192k -pix_fmt yuv420p -t 1840 easywords2.mp4

Convert MP3 to WAV

  • install mpg321 (not 123 which is a slightly worse program because not on public licence)
  • put the to-be-created wav title first
  • mpg321 -w newFile.wav “old file.mp3"
  • mpg321 -w ZOOM0061.WAV ZOOM0061.mp3

Clean metadata

ffmpeg

  • because it does a better job of combining audio with a single image than Kdenlive (which makes big files) (it has no GUI though, so use HandBrake) (I didn't find it to be very much better on initial tests)
  • Handbrake
  • add-apt-repository sudo apt-get update
  • sudo apt-get install handbrakeppa:stebbins/handbrake-git-snapshots

Chmod execute scripts

  • change mod it with (you have to be in the directory) (otherwise it will look for a system path):
  • chmod +x myscript.sh
  • to execute it then, do
  • ./myscript.sh

PDF TO TEXT

qpdf orig.pdf --pages . 420-511 -- just-the-chapters.pdf && convert -density 288 just-the-chapters.pdf output-%02d.jpg && convert output.jpg -level 25% final-%02d.jpg && convert final.jpg vr.pdf && ocrmypdf -l spa vr.pdf bookonech11-12.pdf && pdftotext -layout bookonech11-12.pdf bookonech11-12.txt && rm output* && rm final* && rm vr.pdf && rm just-the-chapters.pdf

Batch crop images (imagemagick)

mogrify*.png -crop 1x1-100-100@ *.jpg

https://deparkes.co.uk/2015/04/30/batch-crop-images-with-imagemagick/

Do

  • mogrify -crop 300x300+150+150 -path ./cropped *.png
  • An example line which is just to illustrate:
  • convert -crop x_sizexy_size+x_offset+y_offset inputfile outputfile

convert *.png -crop 350x300+150+200 *.jpg


*Modify metadata for 'date modified' (on Linux it seems that there's no ability to modify creation date, even with filesystems that allow it ie exfat etc)**

  • go to folder and put all the files you want to modify, and open a Terminal there
  • touch *

Comments: 0

Interested to discuss? Leave a comment.

Image




Your email will not be published nor shared with anyone. In your text you can use markdown for marking up *italic*, links <http://example.org> and other elements. These comments are moderated and published manually as soon as possible.