UrFix's Blog

A geek without a cause

  • Naughty Linux

    by

    Sometimes when you type in the command line you don’t realize what you are actually saying. Unzip, mount, finger. Someone might over hear you and think your a pervert.

     

    Here’s an example:

  • Top 10 Awesome Linux Screen Tricks

    by

    Screen or as I like to refer to it “Admin’s little helper”
    Screen is a window manager that multiplexes a physical terminal between several processes

    here are a couple quick reasons you’d might use screen

    Lets say you have a unreliable internet connection you can use screen and if you get knocked out from your current session you can always connect back to your session.

    Or let’s say you need more terminals, instead of opening a new terminal or a new tab just create a new terminal inside of screen

    Here are the screen shortcuts to help you on your way Screen shortcuts

    and here are some of the Top 10 Awesome Linux Screen tips urfix.com uses all the time if not daily.

     

    1) Attach screen over ssh

    ssh -t remote_host screen -r
    

    Directly attach a remote screen session (saves a useless parent bash process)

    2) Share a terminal screen with others

    % screen -r someuser/

    3) Triple monitoring in screen

    tmpfile=$(mktemp) && echo -e 'startup_message off\nscreen -t top  htop\nsplit\nfocus\nscreen
    -t nethogs nethogs  wlan0\nsplit\nfocus\nscreen -t iotop iotop' > $tmpfile &&
    sudo screen -c $tmpfile
    
    

    This command starts screen with ‘htop’, ‘nethogs’ and ‘iotop’ in split-screen. You have to have these three commands (of course) and specify the interface for nethogs – mine is wlan0, I could have acquired the interface from the default route extending the command but this way is simpler.

    htop is a wonderful top replacement with many interactive commands and configuration options. nethogs is a program which tells which processes are using the most bandwidth. iotop tells which processes are using the most I/O.

    The command creates a temporary “screenrc” file which it uses for doing the triple-monitoring. You can see several examples of screenrc files here: http://www.softpanorama.org/Utilities/Screen/screenrc_examples.shtml

    4) Share a ‘screen’-session

    screen -x
    

    Ater person A starts his screen-session with `screen`, person B can attach to the srceen of person A with `screen -x`. Good to know, if you need or give support from/to others.

    5) Start screen in detached mode

    screen -d -m [<command>]
    

    Start screen in detached mode, i.e., already running on background. The command is optional, but what is the purpose on start a blank screen process that way?
    It’s useful when invoking from a script (I manage to run many wget downloads in parallel, for example).

    6) Resume a detached screen session, resizing to fit the current terminal

    screen -raAd.

    By default, screen tries to restore its old window sizes when attaching to resizable terminals. This command is the command-line equivalent to typing ^A F to fit an open screen session to the window

    7) use screen as a terminal emulator to connect to serial consoles

    screen /dev/tty<device> 9600
    

    Use GNU/screen as a terminal emulator for anything serial console related.

    screen /dev/tty

    eg.

    screen /dev/ttyS0 9600

     

    8) ssh and attach to a screen in one line.

    ssh -t user@host screen -x <screen name>
    

    If you know the benefits of screen, then this might come in handy for you. Instead of ssh’ing into a machine and then running a screen command, this can all be done on one line instead. Just have the person on the machine your ssh’ing into run something like
    screen -S debug
    Then you would run
    ssh -t user@host screen -x debug
    and be attached to the same screen session.

    9) connect to all screen instances running

    screen -ls | grep pts | gawk '{ split($1, x, "."); print x[1] }' | while read i; do gnome-terminal -e screen\ -dx\ $i; done

     

    connects to all the screen instances running.

    10) Quick enter into a single screen session

    alias screenr='screen -r $(screen -ls | egrep -o -e '[0-9]+' | head -n 1)'

    There you have ’em folks the top 10 screen commands. enjoy!

  • Create A File And Loop It As A Filesystem in Linux

    by

    Create A File And Loop It As A Filesystem in Linux

    Associating file systems to storage devices in Linux is called mounting. The mount command is used to attach a file system to a file system hierarchy. To mount, you provide a file system type, a file system, and a mount point.

    To demonstrate the capabilities of the Linux file system layer , create a file system in a file within the current file system. This is achieved by creating a file of a given size using dd in other words, a file initialized with zeros, as shown in figure 1.

    Figure 1. Creating an initialized file

    $ dd if=/dev/zero of=file.img bs=1k count=10000
    10000+0 records in
    10000+0 records out
    $

    You now have a file called file.img that is 10MB. Use the losetup command to merge a loop device with the file (making it look like a block device instead of just a regular file within the file system):

    $ losetup /dev/loop0 file.img
    $

    The file now appears as a block device (represented by /dev/loop0), create a file system on the device with mke2fs. This command spawns a new second ext2 file system of the defined size, as shown in Figure 2.

    Figure 2. Creating an ext2 file system with the loop device

    $ mke2fs -c /dev/loop0 10000
    mke2fs 1.35 (28-Feb-2004)
    max_blocks 1024000, rsv_groups = 1250, rsv_gdb = 39
    Filesystem label=
    OS type: Linux
    Block size=1024 (log=0)
    Fragment size=1024 (log=0)
    2512 inodes, 10000 blocks
    500 blocks (5.00%) reserved for the super user

    $

    The file.img file, symbolized by the loop device (/dev/loop0), is now mounted to the mount point /mnt/point1 using the mount command. Note the differentiation of the file system as ext2. When mounted, you can consider this mount point as a new file system by using an ls command, as shown in Listing 3.

    Figure 3. Creating a mount point and mounting the file system through the loop device

    $ mkdir /mnt/point1
    $ mount -t ext2 /dev/loop0 /mnt/point1
    $ ls /mnt/point1
    lost+found
    $

    As shown in Figure 4, you can aggrandize this process by constructing a new file within the new mounted file system, associating it with a loop device, and creating another file system on it.

    Figure 4. Creating a new loop file system within a loop file system

    $ dd if=/dev/zero of=/mnt/point1/file.img bs=1k count=1000
    1000+0 records in
    1000+0 records out
    $ losetup /dev/loop1 /mnt/point1/file.img
    $ mke2fs -c /dev/loop1 1000
    mke2fs 1.35 (28-Feb-2004)
    max_blocks 1024000, rsv_groups = 125, rsv_gdb = 3
    Filesystem label=

    $ mkdir /mnt/point2
    $ mount -t ext2 /dev/loop1 /mnt/point2
    $ ls /mnt/point2
    lost+found
    $ ls /mnt/point1
    file.img lost+found
    $

    From this simple presentation, it is easy to see how powerful the Linux file system is. You can use this same technique to create encrypted file systems with the loop device on a file. This is beneficial to protect your data by  metaphorically mounting your file using the loop device when needed.

     

  • Secret Hidden Menu Hack and Tethering LG Octane On Linux

    by

    LG Octane Secret Menu

    There are some pretty cool hidden menu options available on Verizon Wireless LG model cellphone? Using these menu options one can unlock the secret GPS system and MP3 sections on any LG phone.

    Warning: this may severely damage your phone if you change certain settings!

    Open your phone so that the main screen is displayed.
    press ##program530,  ##7764726530 then send and a screen should pop up with the words “SERVICE CODE” at the top followed by six question marks
    Enter all zeroes  and you should be taken to a menu that reads “Services” with the following under

    ##LGSERVICEMENU hit send
    the password is all zero’s

    * Changing values that you don’t have knowledge about in the service menu may damage your phone.
    * The functionality of the Hidden GPS system varies from phone.

     

    Using your LG Octane as a Modem on Linux

    Click on the System Menu under preferences click on Network Connections

    Click on the Mobile Broadband tab

    Click the “Add” button

    You should see LG CDMA USB Modem

    if you don’t see it make sure you select modem mode on your phone

    Otherwise click Foward

    Select your country and click foward

    The next screen ask you to pick your provider select Verizon and hit foward. Finally hit apply

    Now under Mobile Broadband you should see your new connection. select it and click the Edit button.

    Under Mobile Broadband make sure #777 is set as number

    username and password blank

    under PPP Settings uncheck Use point-to-point encrytion (MPPE)

    follow these settings

    ppp settings for lg

    Finally Click on the “Configure Methods” button

    and follow these settings

     

    Hit Ok and Finally Apply.

    Now left click on the Network Manager applet and connect to your new connection.

    Have fun

     

     

     

     

     

     

Chat

Hi 👋, how can we help?