Skip to main content

Posts

Showing posts with the label Linux

Demystify - Linux GUI

GUI In Linux GUI ( Graphics User Interface ) as everyone know about.  I am writing this article so that we can able to understand how to run GUI apps in containers but we need to understand how it works in linux. Why linux?   Most of the container we use are Linux based inorder run GUI in Linux we need know how it works.. Back in early days computer fill the entire room and if you want to access it you will be presented TTY (TeleType Machine) you can still see this screen if you press CTRL + ALT + F1 in Linux. ( To get back to GUI press CTRL + ALT + F7 ) Linux spin off 8 TTY when it boots ( we can configure more or less ) Graphics in linux is handled by bunch of little programs. They are Display manager Display manger which is the key component for graphics in which mainly graphics servers lie in linux the X.org is the defacto of Display manger. which has two components X Server  X Client Here little twist server talks to the client ( o...

Vim - Text Editor which last for Decade

what's Vim?     Vim is a highly configurable text editor for efficiently creating and changing any kind of text. It is included as "vi" with most UNIX systems and with Apple OS X                                                                                                            ---> From Vim.org  when i first heard it, what a command line editor which is awesome and i said to myself  NO WAY, there are tons of editor which looks good and easy learn curve such as Atom,Sublime,VSCode and bunch others What makes vim special than other editors?  Different from everything you have used before ( because it has modes - insert mode,visual mode,Command mode ) Forget the mouse ( why?...

Handy Linux Commands

Awesome commands that can make your work lot more simpler if you wish to delete a file which is older than x minutes, you can use the below command find . - type f - mmin + 30 - delete   Run script in all directory find . -type d -execdir /path/to/script.sh {} \; you can also execute commands How to sort the finded file based on Size find . - type f - iname "*.$extension" - print0 | xargs - 0 ls - lS How to print all the file in Directory and separate by Line (============== ) find . -type f -exec cat -n {} \; -exec echo "==================================================" \;  How to move particular files from one directory to other directory  find . -iname "*.csv" -type f | xargs -I '{}' mv {} ~/data/csv here we copy all csv file from current directory to ~/data/csv folder Split single line into multiple lines example: I/p: A,B,C,D,E,F,G,H,I,J,K,L,M,N,O   O/p:   A,B,C D,E,F G,H,I J,K,L M,N,O     this ...

My First CTF Adventure

Overthewire is a website which offer wargames that help you learn and practice security concepts in the form of fun-filled games My first game is Bandit . What special about this Game?               These game teach you basic Linux terminal usage and tricks ( using commands in a way you never even imagine ) and the best part is more you play more you learn  Whether it is easy or hard to solve a challenge?               To be honest,It is hard and makes you think out of the box but at the end you will fell i learned something cool. Does this help me with Daily chores?               Yes, knowing few tricks in command line can save tons of your time. let me give a example you need to remove the duplicate line in Log file or find occurrence of line which can be done using single...

Enable or Disable USB in Linux

To Enable / Disable USB  To really disable and enable USB, lets say port 3 and device 2 (you can get the information from lsusb -t) echo '3-2' | sudo tee / sys / bus / usb / drivers / usb / unbind echo '3-2' | sudo tee / sys / bus / usb / drivers / usb / bind Another Method chmod 000 /media/  here is where device is mounted hence make it 000 -> not able to read or write files chmod 777 /media/   extact opposite to above i.e able to read and write the files the above chmod is nothing but change mode which is a part of unix/linux code mainly used for read or write permission that can be represented by numbers.

Encryption and Decryption in Linux - I

Encryption:           Nothing but the conversion of plain text to cipher text(not understandable). Decryption:          It's conversion of  cipher text to plain text. There are wide variety of tools to achieve it.This post deal with rapid fire commands that you can throw at terminal Tools used:        [+] Openssl        [+] tr        [+] base64 Mostly the above tools are preinstalled in lot of distribution if not download it from software repository Let's get started {1} BASE64 encryption and decryption   Most widely used algorithm for simple encryption and decryption for conversion of binary data into ASCII format ( Used in MIME for conversion of Non-ASCII to ASCII characters ) More details click the above link. To convert binary to ASCII uses below commands         ...

Freeze a Process in Linux

i am very much intrested in freezing a process things i studied in distributed system i want to try it what happen when process is freezed?     The process gets inactive(i.e whatever you press keyboard or mouseclick the program will not listen)more simply you can see application and you cannot do anything Let's see how to do it  First we need to find pid(Process IDentifier) of the process using pidof      this can be done using pidof <appname>                                            eg: pidof firefox Then note all the pid and pass it to below command              kill -STOP <pid1..n> now your app become inactive to activate it use the below command ...

Stop a process after certain time in Linux

i was wondering if there is any way we can run a process upto certain time , i.e i want to run cat file_name timelimit  is 1 seconds try this for big file so to do that i found two ways let's see i] Using program come from GNU coreutils " timeout "             timeout [OPTION] DURATION COMMAND [ARG]. for easy understanding try below example              timeout 1s cat file_name  1s => run for second for minute 'm' for hour 'h' cat => COMMAND file_name => argument for the command 'cat' and donot forget to check the Manual Page " man timeout " hit the terminal. ii] Using a shell script program program_name & sleep 20s killall program_name Line 1: The first line tells you run the program in background if you want in foreground remove the & Line 2: delay for 20seconds for minute 'm' for hour 'h' and checkout man page. Line 3: I...

Failed to start File System Check on /dev/disk/by-uuid/

Failed to start File System Check on /dev/disk/by-uuid/your-uuid of disk   dependency failed to mount something such as /home or / so there are some data got corrupted put you in hell enter into heaven by entering below code   fsck -AR -y     fsck - check and repair linux file system   for more details check out " man fsck "   this command will delete all corrupted file from the drive   stop from further error: Donot shutdown by power button of laptop use " systemctl poweroff "   Reference: https://bbs.archlinux.org/viewtopic.php?id=200772

linux tools digged from web

crash == to analysis linux crash motion == motion detecter from webcam pantheon == desktop environment for Elementary os linux-manpages == for kernal hackers tensi == the system log viewer from gentoo linux xorg-xmag == magnify the part of screen usbip == share the usb across ip wxcam == linux webcam application snownews == command line rss reader for linux twin == text based window environment thrift == cross - platform IPC/RPC (used in osquery i.e facebook opensource software) st == virtual terminal emulator for linux sslscan == to scan ssl service i.e in HTTPS sonic-visualizer == viewer and analyzer for audio files quvi == command  line tools for parsing video links pfff == tools and api for code analysis and visualization and transformation lockdev == runtime locking of device this apps can be installed using ubuntu and debian users sudo apt-get install <app-name>  Arch linux sudo pacman -S <app-name> ...

Few important thing in linux world

Changing permissions with chmod (numbers) If you own a fi le, you can use the chmod command to change the permission on it as you please. In one method of doing this, each permission (read, write, and execute) is assigned a number — r=4, w=2, (important) x=1 — and you use each set’s total number to establish the permission. For example, to make permissions wide open for yourself as owner, you would set the fi rst number to 7 (4+2+1), and then you would give the group and others read-only permission by setting both the second and third numbers to 4 (4+0+0), so that the fi nal number is 744. Any combination of permissions can result from 0 (no permission) through 7 (full permission). chmod 777 file Changing permissions with chmod(letters) you can change permission for the user (u), group (g), other (o), and all users(a). What you would change includes the read (r), write (w), and execute (x) bits Metacharacters in file matching * — Matches any num...

Linux Commands

few commands which is taken from web surfing # Suspend process: Ctrl + z # Move process to foreground: fg # Generate random hex number where n is number of characters: openssl rand -hex n # Execute commands from a file in the current shell: source /home/ user / file . name # Substring for first 5 characters: ${variable:0:5} # SSH debug mode: ssh -vvv user @ip_address # SSH with .pem key: ssh user @ip_address -i key .pem # Get complete directory listing to local directory with wget: wget -r -- no -parent - -reject "index.html*" http://hostname/ -P /home/ user /dirs # Create multiple directories: mkdir -p /home/ user /{test , test1 , test2} # List processes tree with child processes: ps axwef # Make .war file: jar -cvf name .war file # Test disk write speed: dd if = /dev/zero of=/tmp/output.img bs=8k count=128k conv=fdatasync ; rm -rf /tmp/output.img # Test disk read speed: hdparm -Tt /dev/sda # Get md5 hash from text: echo -n "text...