Tagged: shell Toggle Comment Threads | Keyboard Shortcuts

  • John Cartwright 2:33 PM on May 12, 2016 Permalink | Reply
    Tags: , , , shell,   

    Location of the filesystem that the Windows 10 bash shell uses. 

    This is the location of the actual files that are installed when you install the Windows 10 bash shell. This means that it is not really a ext4 filesystem, but emulating this when you load it up in a CMD window.


    The location of the actual filesystem the Windows 10 bash shell uses. Very interesting find.

    Windows 10 bash shell files.

    Windows 10 bash shell files.

    This is the default .bashrc used by the Windows 10 bash shell.

    # ~/.bashrc: executed by bash(1) for non-login shells.
    # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
    # for examples
    # If not running interactively, don't do anything
    case $- in
        *i*) ;;
          *) return;;
    # don't put duplicate lines or lines starting with space in the history.
    # See bash(1) for more options
    # append to the history file, don't overwrite it
    shopt -s histappend
    # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
    # check the window size after each command and, if necessary,
    # update the values of LINES and COLUMNS.
    shopt -s checkwinsize
    # If set, the pattern "**" used in a pathname expansion context will
    # match all files and zero or more directories and subdirectories.
    #shopt -s globstar
    # make less more friendly for non-text input files, see lesspipe(1)
    [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
    # set variable identifying the chroot you work in (used in the prompt below)
    if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
        debian_chroot=$(cat /etc/debian_chroot)
    # set a fancy prompt (non-color, unless we know we "want" color)
    case "$TERM" in
        xterm-color) color_prompt=yes;;
    # uncomment for a colored prompt, if the terminal has the capability; turned
    # off by default to not distract the user: the focus in a terminal window
    # should be on the output of commands, not on the prompt
    if [ -n "$force_color_prompt" ]; then
        if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
    	# We have color support; assume it's compliant with Ecma-48
    	# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
    	# a case would tend to support setf rather than setaf.)
    if [ "$color_prompt" = yes ]; then
        PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
        PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
    unset color_prompt force_color_prompt
    # If this is an xterm set the title to [email protected]:dir
    case "$TERM" in
        PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    # enable color support of ls and also add handy aliases
    if [ -x /usr/bin/dircolors ]; then
        test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
        alias ls='ls --color=auto'
        #alias dir='dir --color=auto'
        #alias vdir='vdir --color=auto'
        alias grep='grep --color=auto'
        alias fgrep='fgrep --color=auto'
        alias egrep='egrep --color=auto'
    # some more ls aliases
    alias ll='ls -alF'
    alias la='ls -A'
    alias l='ls -CF'
    # Add an "alert" alias for long running commands.  Use like so:
    #   sleep 10; alert
    alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
    # Alias definitions.
    # You may want to put all your additions into a separate file like
    # ~/.bash_aliases, instead of adding them here directly.
    # See /usr/share/doc/bash-doc/examples in the bash-doc package.
    if [ -f ~/.bash_aliases ]; then
        . ~/.bash_aliases
    # enable programmable completion features (you don't need to enable
    # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
    # sources /etc/bash.bashrc).
    if ! shopt -oq posix; then
      if [ -f /usr/share/bash-completion/bash_completion ]; then
        . /usr/share/bash-completion/bash_completion
      elif [ -f /etc/bash_completion ]; then
        . /etc/bash_completion
  • John Cartwright 1:08 PM on April 18, 2016 Permalink | Reply
    Tags: , , , shell,   

    Windows 10 bash shell not very impressive at all. 

    The new Windows 10 bash shell is not very impressive once you get it installed. I have tried it and I could not ping websites even though Microsoft Edge could access the Internet. It is possible to install packages if these lines are added to the /etc/hosts file. archive.ubuntu.com security.ubuntu.com

    But using ping does not work. I cannot even add a static route with the ip route add command. Microsoft really need to fix this. I would use this if I could use links or lynx to browse Slashdot in a CMD window on a Windows 10 desktop. But since I have Debian Jessie installed on my laptop with the Kali Linux package repositories merged in, it is a little redundant. There is a big fuss about the Windows 10 bash shell, but it needs a lot of work before it is even usable. In a Virtual Machine in VMware running on a computer with 12 Gigabyes of RAM with 4 Gigabytes devoted to the VM, it keeps stopping and I have to press ENTER to keep an operation going like an APT update. I have no idea why this is. Better to run Debian Jessie in a VM and SSH into it and get a bash shell on your desktop that way.

    Linux has come a long way since the early days, now I can run a Linux shell on my Android phone that supports apt-get. But the Microsoft alternative is quite underwhelming. A pity, it promised so much but is delivering so little. There are so many reports of Internet connectivity issues: https://github.com/Microsoft/BashOnWindows/issues/5. Why can they not fix this? Offer a generic network driver that is always connected to the host using NAT and allows Internet access? If your machine was behind a proxy, adding proxy information to /etc/apt/apt.conf would be required, but this should work fine. Possibly they need to virtualise a network connection and always allow Internet access. If the CMD and Powershell windows can access the Internet why not the Debian Linux bash shell? Although Microsoft have apparently not yet implemented ICMP sockets. This is why ping does not work.

    One person suggested disabling the Windows Firewall completely and this fixed the problems they were having, but this would be a bad thing. Once the problems are sorted out, this might actually be a useful tool, but not yet.

  • John Cartwright 10:27 PM on April 12, 2016 Permalink | Reply
    Tags: , , shell,   

    Windows 10 bash shell 10.0.14316 very good for getting system information. 

    The new bash shell in Windows 10 build 10.0.14316 is the best addition to Windows 10 yet. Here I am getting information about the CPU.

    root@localhost:/mnt/c/Users/johnc# cat /proc/cpuinfo
    processor       : 0
    vendor_id       : GenuineIntel
    cpu family      : 6
    model           : 60
    model name      : Intel(R) Core(TM) i5-4670K CPU @ 3.40GHz
    stepping        : 3
    microcode       : 0xffffffff
    cpu MHz         : 3399.000
    cache size      : 256 KB
    physical id     : 0
    siblings        : 1
    core id         : 0
    cpu cores       : 1
    apicid          : 0
    initial apicid  : 0
    fpu             : yes
    fpu_exception   : yes
    cpuid level     : 6
    wp              : yes
    flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave osxsave avx f16c rdrand hypervisor
    bogomips        : 6798.00
    clflush size    : 64
    cache_alignment : 64
    address sizes   : 36 bits physical, 48 bits virtual
    power management:

    The networking does not work with this shell, so you cannot install any programs or ping websites, but the prompt is useful for using various commands. I am not sure why, there is no networking device available to create a static route. I have entered values into the /etc/resolv.conf, but this useless with no networking support. So you could not use the Lynx browser in a CMD window to browse Slashdot. But if the user has VMware, then Debian Jessie could be installed and this used to access a Linux command prompt.

    The vmstat command is there, but the /proc filesystem is not working.

    But I can use the lscpu command to get CPU information.

    root@localhost:/mnt/c/Windows# lscpu
    Architecture:          x86_64
    CPU op-mode(s):        32-bit, 64-bit
    Byte Order:            Little Endian
    CPU(s):                1
    On-line CPU(s) list:   0
    Thread(s) per core:    1
    Core(s) per socket:    1
    Socket(s):             1
    Vendor ID:             GenuineIntel
    CPU family:            6
    Model:                 60
    Stepping:              3
    CPU MHz:               3399.000
    BogoMIPS:              6798.00
    Hypervisor vendor:     VMware
    Virtualization type:   full

    Even piping works.

    root@localhost:/mnt/c/Windows# lsof | grep txt
    init      1 root  txt       REG    0,0   22856 1407374883651976 /init
    bash      2 root  txt       REG    0,0 1021112 1125899906944571 /bin/bash
    lsof     81 root  txt       REG    0,0  163224  562949953616850 /usr/bin/lsof
    grep     82 root  txt       REG    0,0  191952 1125899906944574 /bin/grep
    lsof     83 root  txt       REG    0,0  163224  562949953616850 /usr/bin/lsof

    But not much else. Better to stick with a native Debian Jessie or Ubuntu 16.04 installation. This is shit without networking capability.

  • John Cartwright 12:17 PM on April 11, 2016 Permalink | Reply
    Tags: , , shell,   

    Windows 10 getting a Linux shell. 

    Windows 10 is getting a bash shell in the summer release. This is a couple of months away. But here are a couple of screenshots from developers I have found on the web that show what this will look like. Here a person is installing the bash shell using CMD.

    Windows 10 bash shell installing.

    Windows 10 bash shell installing.

    Now this is the bash shell running.

    Ubuntu bash shell running on Windows 10.

    Ubuntu bash shell running on Windows 10.

    This person is using a root prompt. The /proc filesystem is even in place, the systems administrator is even able to get information about the CPU using /proc/cpuinfo. This means that the admin could use existing UNIX shell scripts on Windows, instead of rewriting them for the Powershell scripting language. I cannot wait for this to be released to the general public so that I can get a hold of this. I tried updating Windows 10 to the fast ring and enabling developer mode, but this does not work yet, I will wait a few months until the “stable” build of Windows 10 X64 has this feature. Or you could just install Ubuntu 16.04 in a VMware VM and then SSH into it from Bitvise or Putty. Same thing really.

    Apparently, the prompt will not have the ability to overwrite certain files on the filesystem.

    Bash shell on Windows 10.

    Bash shell on Windows 10.

    I wonder if the bash shell supplied with this is vulnerable to shellshock…

  • John Cartwright 12:52 PM on March 31, 2016 Permalink | Reply
    Tags: , , , shell,   

    Linux bash shell coming to Windows 10. 

    Apparently, the Linux bash shell is coming to Windows 10. This will offer a fully functional Linux bash prompt in the Windows app store, a good alternative to Powershell. This is in partnership with Canonical who work on the Ubuntu Linux distribution. As long as this offers tools such as dig, wget, and whois, it will be a very powerful tool for Windows system administration. A good thing to partner with Powershell, which has commands to start and stop Windows services and install features for Windows. This was announced at the Build Developer Conference. The Linux bash shell has been in Linux for a very long time, since 1989. It has extensive support for scripting and therefore is used in the Linux installation to automate many tasks. If this could be used in Windows 10 to script various administration tasks, it would be a good tool for any systems admin who is skilled in the Linux shell. Microsoft are embracing open-source software in a big way, I hope this is not an attempt to extinguish the competition, such as Red Hat Enterprise Linux, Fedora Server and Ubuntu server products.

    Microsoft even have a Github account with quite a few open-source programs they have released, a huge list indeed. This is what they need to compete in the modern world, a lot of modern server tasks such as web hosting, file servers, printer servers and workgroups can be done on Linux with Apache and SAMBA. So Microsoft must adapt to compete with Linux and UNIX. If only they could improve the code-base of Windows, apparently, it is a huge mess in Windows 10. Pushing a massive code-base like Windows 10 with all sorts of code embedded together in the one operating system. If they could start a parallel project to start a whole new Windows operating system that would use a whole new code-base, that would be a very good project, but this would be very costly. I would love to see Microsoft take a risk and develop an entire Windows operating system from scratch. Redmond seem to be focused on the bottom line, getting the new Windows release out there, without worrying about whether it will work on all modern machines. Windows 10 does have Directx 12 coming, which will be used by the new Arma 3 Apex update, but I will stick with Windows 7 for a good while.

    Windows 7 is still supported until 2020. This is still a few years away yet. And it is still getting updates. This is just like the Linux prompt you could install in Windows Server 2008 and 2003. This offered a csh shell that could run many Linux commands on a Windows Server PC. Microsoft Services for UNIX allowed this functionality.

  • John Cartwright 11:09 AM on January 7, 2016 Permalink | Reply
    Tags: beiber, , justin, shell,   

    Gnome Shell Linux interface in Justin Beiber music video. 

    This music video features a Macintosh iMac PC with the Gnome Shell Linux interface. This is used as the main screen where the girl is typing on a notepad and then ripping the pages off the screen. This is an interesting place to see the Gnome Shell Linux desktop environment. You would have thought that the producers would have used Mac OSX, but I guess Linux is free and this was the natural choice.

    Justin Bieber – Sorry (Lyric Video)


  • John Cartwright 1:53 PM on November 17, 2015 Permalink | Reply
    Tags: , , , shell   

    How to generate a random password using the command line. 

    The shuf command for Linux allows a command-line user to select a given number of random words from a wordlist.

    [jason@localhost ~]$ shuf -n 8 /usr/share/dict/words

    This can be used to generate a word based password using piping. The example below shows how to generate a random password using the command line.

    [jason@localhost ~]$ shuf -n 4 /usr/share/dict/words | paste -s -d ''

    This is another example, this generates a random password string that may be used for any login.

    [jason@localhost ~]$ shuf -n 4 /usr/share/dict/words | awk '{print toupper(substr($0,1,1)) substr($0,2)}' | cut -d\' -f1 | tr -d '\n' ; echo

    Yet another example, generate an unbreakable password.

    [jason@localhost ~]$ tr -dc "[:print:]" < /dev/urandom | head -c 128 ; echo
  • John Cartwright 12:43 PM on January 2, 2015 Permalink | Reply
    Tags: , , , shell,   

    Some useful bash shell scripts for the Linux user. 

    This function will allow your computer to speak.

    function shellspeak()
           mplayer "http://translate.google.com/translate_tts?tl=en&q=$(echo $@ | sed 's/\s/+/')" > /dev/null 2>&1;

    A script that will change all files in a directory to lowercase filenames.

    function lowercase()  # move filenames to lowercase.
        for file ; do
            case "$filename" in
            */*) dirname==${file%/*} ;;
            *) dirname=.;;
            nf=$(echo $filename | tr A-Z a-z)
            if [ "$nf" != "$filename" ]; then
                mv "$file" "$newname"
                echo "lowercase: $file --> $newname"
                echo "lowercase: $file not changed."

    A function that will check for all invalid symlinks in a directory.

    function badlink()
    # From Atomic magazine #43 August 2004. http://www.atomicmpc.com.au
    	DEFAULT=$(tput sgr0);
    	[ -e $FILELIST ] && $( rm -fr $FILELIST )
    	function checklink()
    		for badlink in $1/*; do
    			[ -h "$badlink" -a ! -e "$badlink" ] && echo \
    			\"$badlink\" >> $FILELIST
    			[ -d "$badlink" ] && checklink $badlink
    	for directory in `pwd`; do
    		if [ -d $directory ] ; then
    			checklink $directory;
    	if [ -e $FILELIST ] ; then
    		for line in $(cat $FILELIST); do
    			echo $line | xargs -r rm | echo -e "$line \
    		rm -fr $FILELIST
    		printf "Bad symlinks not found.\n\n"
    } # End Atomic function.

    Get your network IP addresses easily with this simple function.

    function my_ip() # get IP adresses. Bracket on next line C style...
        MY_IP=$(/sbin/ifconfig wlan0 | awk '/inet/ { print $2 } ' | sed -e s/addr://)
        MY_ISP=$(/sbin/ifconfig wlan0 | awk '/P-t-P/ { print $3 } ' | sed -e s/P-t-P://)

    Get user information from the shell.

    if [ -x /usr/bin/finger ] ; then
       INFO=$(finger -lmps $LOGNAME | sed -e "s/On/Logged in/g" | grep "since" )
       INFO=$(uname -msov)
    echo -ne "${INFO}\n"
  • John Cartwright 10:06 PM on December 10, 2014 Permalink | Reply
    Tags: , , messages, shell, wall   

    How to send a message to logged on users on your Linux system with a simple command. 

    The wall command is a perfect way to send a message to all logged on users on a Linux machine. This is used when you shutdown to alert all users that the system will be shutting down. The example below shows me sending the output of the ps command to all users.

    [email protected]:~$ sudo ps | wall
    Broadcast Message from ubuntu@ip-172-3
            (/dev/pts/0) at 10:41 ...
      PID TTY          TIME CMD
    14307 pts/0    00:00:00 sudo
    14309 pts/0    00:00:00 ps

    Here is a more useful example, this shows how to alert your users of upcoming server maintenance.

    [email protected]:~$ sudo echo "The server will be rebooting in aproximately 15 minutes, please save your work." | wall
    Broadcast Message from ubuntu@ip-172-3
            (/dev/pts/0) at 10:46 ...
    The server will be rebooting in approximately 15 minutes, please save your work.

    This is a perfect way to alert users on terminals that the server will be experiencing maintenance.

    If you use the -n parameter to the wall command, you can hide your identity. This could be fun… You must be root to use the nobanner option though.

    root@ip-172-31-20-234:/home/ubuntu# echo "Hello" | wall -n

    Try this out in a script, a user could have an alert that sent out messages when disk space was running low, this could be very useful indeed.

  • John Cartwright 12:31 PM on December 8, 2014 Permalink | Reply
    Tags: , navigate, shell,   

    More useful bash tricks for navigating your filesystem. 

    To navigate back to the last directory you were in, type cd -. This will take you back to where you were before.

    The cd ~ command will take you back to your home directory.

    The user can also use the cd command by itself to go back to the home directory.

    Using cd .. will take you back one directory.

    TRON Legacy UNIX login. They got this right!

    TRON Legacy UNIX login. They got this right!

    When editing a command line in bash, use Ctrl-a to go to the start of the command and Ctrl-e to go to the end.

  • John Cartwright 9:26 PM on October 18, 2014 Permalink | Reply
    Tags: , , , shell,   

    How to change the default shell for new users on your Ubuntu Linux system. 

    The useradd command is used to add new users on your Linux system. But it can be used for other things too.

    You may display the defaults for new users.

    jason-H55-USB3% sudo useradd -D             

    Use the -s parameter to useradd and this will change the default shell for new users.

    sudo useradd -D -s /bin/sh

    Very easy indeed.

  • John Cartwright 5:15 PM on September 30, 2014 Permalink | Reply
    Tags: , , , , shell, shock   

    A variant of the shellshock bug that still works with the bash 4.3.11 shell. 

    This is a variant of the shellshock bug for bash that still works on a patched system. I am using Ubuntu 14.04 and this still works for me.

    env VAR1='me() {echo "hello"}\ ' /bin/touch /home/$LOGNAME/my.text

    So you can still put arbitrary content after the function definition in a bash script. I have installed the latest bash updates and this still works. So this has quite a way to go to be fully secure. Better to use another shell. I used the /bin/dash shell as a replacement for my default bash shell on Ubuntu. There is also this method using telnet that uses environment variables that can inject malicious code into a CGI script running on an Apache2 website.

    telnet google.com 80                                                                                                                         [14-09-27 23:07:14]
    Trying 2607:f8b0:4005:800::1007...
    Connected to google.com.
    Escape character is '^]'.
    HTTP/1.1 GET /
    Host: google.com
    User-Agent: () { :;}; rm -rf /
    Accept: */*

    This vulnerability must be fixed, but how do you create a regex that can check every possible permutation of malicious code inserted after a bash function. I recommend using csh or ksh instead of bash. There are no “remote” exploits for the Linux bash shell. Bash does not have network connectivity. The only way that this could be actually exploited is if the remote server has an SSH service running that is forwarded to the Internet. There may be remote code execution vulnerabilities when bash is used in connection with a network service like a web-server. CGI scripts could be vulnerable to this attack. But patching your system should be of the utmost concern when dealing with this problem. That is the best way to keep your Internet connected systems protected from attack. That and a good firewall.

    • John Cartwright 4:25 PM on October 1, 2014 Permalink | Reply

      I just tested this on an updated Amazon AWS instance with all updates and this still works on Ubuntu server 14.04. Time to switch to a different shell.

  • John Cartwright 1:16 PM on September 15, 2014 Permalink | Reply
    Tags: , , , hogs, , shell,   

    How to list all files in a directory that are larger than one megabyte. 

    Use this command to find all files in a directory that are larger than 1 megabyte.

    find . -maxdepth 1 -type f -size +1M -exec ls -Shal {} \+ | head

    Here is this command in practice. This is a very useful command.

    ubuntu@ip-172-31-20-234:/boot$ find . -maxdepth 1 -type f -size +1M -exec ls -Shal {} \+ | head
    -rw-r--r-- 1 root root 7.4M Sep 10 04:05 ./initrd.img-3.13.0-29-generic
    -rw------- 1 root root 5.6M Jun  4 21:57 ./vmlinuz-3.13.0-29-generic
    -rw------- 1 root root 3.3M Jun  4 21:57 ./System.map-3.13.0-29-generic
    -rw-r--r-- 1 root root 1.2M Jun  4 21:57 ./abi-3.13.0-29-generic
    This command shows how to list all files that are larger than 1024 kilobytes.
    <pre lang="bash">
    find . -maxdepth 1 -type f -size +1024k -exec ls -Shal {} \+ | head

    Again, here is this command in action.

    ubuntu@ip-172-31-20-234:/boot$ find . -maxdepth 1 -type f -size +1024k -exec ls -Shal {} \+ | head
    -rw-r--r-- 1 root root 7.4M Sep 10 04:05 ./initrd.img-3.13.0-29-generic
    -rw------- 1 root root 5.6M Jun  4 21:57 ./vmlinuz-3.13.0-29-generic
    -rw------- 1 root root 3.3M Jun  4 21:57 ./System.map-3.13.0-29-generic
    -rw-r--r-- 1 root root 1.2M Jun  4 21:57 ./abi-3.13.0-29-generic

    Here I am listing all files larger than 3 kilobytes.

    ubuntu@ip-172-31-20-234:~/easy-rsa$ find . -maxdepth 1 -type f -size +3k -exec ls -Shal {} \+ | head
    -rwxr-xr-x 1 ubuntu ubuntu  13K Sep 14 22:53 ./pkitool
    -rw-r--r-- 1 ubuntu ubuntu 8.3K Sep 14 22:53 ./openssl-0.9.8.cnf
    -rw-r--r-- 1 ubuntu ubuntu 8.2K Sep 14 22:53 ./openssl-1.0.0.cnf
    -rw-r--r-- 1 ubuntu ubuntu 7.7K Sep 14 22:53 ./openssl-0.9.6.cnf

    This is a very useful Linux tip. You can easily list all files larger than a certain size without any problems. This is very good for finding space hogs in a directory.

  • John Cartwright 5:59 PM on September 2, 2014 Permalink | Reply
    Tags: , , , mod, shell,   

    How to change the shell for a user on a Linux system easily with the usermod command. 

    I recently created a new user with the adduser command.

    homer@deusexmachina:~/Documents$ sudo adduser jimkirk
    Adding user `jimkirk' ...
    Adding new group `jimkirk' (1002) ...
    Adding new user `jimkirk' (1002) with group `jimkirk' ...
    Creating home directory `/home/jimkirk' ...
    Copying files from `/etc/skel' ...
    Enter new UNIX password: 
    Retype new UNIX password: 
    passwd: password updated successfully
    Changing the user information for jimkirk
    Enter the new value, or press ENTER for the default
    	Full Name []: 
    	Room Number []: 
    	Work Phone []: 
    	Home Phone []: 
    	Other []: 
    Is the information correct? [Y/n] y

    Now I wanted to change the users shell. I used the usermod command to change this.

    [email protected]:~/Documents$ sudo usermod -s /bin/sh jimkirk

    Now the user has a different shell. This is an easy way to change your own shell as well as modifying another user on your computer system.

    homer@deusexmachina:~/Documents$ sudo grep /bin/sh /etc/passwd
    speech-dispatcher:x:110:29:Speech Dispatcher,,,:/var/run/speech-dispatcher:/bin/sh
    • RoseHosting 9:48 PM on September 2, 2014 Permalink | Reply

      chsh is another command for changing the user shell and it’s easier to remember.

  • John Cartwright 10:28 AM on August 14, 2014 Permalink | Reply
    Tags: , feed, items, , , shell,   

    How to print out a list of all BBC news headlines with the command line. This is very cool. 

    This simple one-liner will print out all of the news headlines from the BBC news website in a simple text format. This is useful if you want to do something with a list like this. Or if you just want a listing to see if there is anything interesting happening.

    [email protected]:~$ curl -s http://feeds.bbci.co.uk/news/rss.xml | grep "<title>" | sed "s/      <title>//g;s/<\/title>//;" | grep -v "BBC News"

    Here is this one-liner in action.

    [email protected]:~$ curl -s http://feeds.bbci.co.uk/news/rss.xml | grep "<title>" | sed "s/      <title>//g;s/<\/title>//;" | grep -v "BBC News"
    National Living Wage comes into force  
    Javid to visit Port Talbot steelworkers  
    Tesla launches 'affordable' Model 3  
    More obese than underweight, says study  
    Police to hire extra firearms officers  
    US and China to co-operate over N Korea  
    Musician sues ROH over ruined hearing  
    Stars turn out for Bowie tribute  
    Brussels airport 'to partially reopen'

    This is a very good way to get a listing of news items in your terminal. Very useful indeed.

    • Don DeGregori 8:40 AM on April 1, 2016 Permalink | Reply

      Very good script, but how do you get rid of the statical data at the top? I want top see just the beginning of the headline and the rest.

      • John Cartwright 5:36 PM on April 1, 2016 Permalink | Reply

        I have updated the post with a new command, and I removed the Slashdot example, as it was not working.

  • John Cartwright 11:01 AM on August 7, 2014 Permalink | Reply
    Tags: ethernet, , , , shell   

    A useful script for gaining information about your Ethernet adapter. 

    This useful shell script will print information about your Ethernet or Wireless adapter. This is very useful for getting a lot of information at once.

    echo "Showing information for the active network interface: $DEV."
    echo -e "-*- \e[1mGet timestamping information for your Ethernet device.\e[0m -*-"
    ethtool -T $DEV
    echo -e "-*- \e[1mPrinting main information about the Ethernet device.\e[0m -*-"
    ethtool $DEV
    echo -e "-*- \e[1mPrinting out the permanent hardware address.\e[0m -*-"
    ethtool -P $DEV
    echo -e "-*- \e[1mPrinting Ethernet adapter IP address.\e[0m -*-"
    # This tip from: http://unix.stackexchange.com/questions/103241/how-to-use-ifconfig-to-show-active-interface-only
    ifconfig | grep "inet " | grep -v | sed -e 's/Bcast//' | cut -d: -f2

    This script uses the ethtool command. This is very good for gaining IP address info as well as other useful information.

  • John Cartwright 1:07 PM on July 15, 2014 Permalink | Reply
    Tags: , , shell, , ,   

    Some useful Linux scripts for the desktop Linux user who likes the command line. 

    There are many useful Linux tips that make the life of a Linux user much easier. One is for the VI or VIM editor. To open a file at a specific line; use this command.

    homer@deusexmachina ~/Documents/yadex-1.7.901 $ vim src/x11.h +33

    This will open the file x11.h at line 33.

    How to ssh into a machine and open a specific directory.

    homer@deusexmachina ~ $ ssh -t homer@localhost -p 443 'cd /tmp && exec $SHELL'
    LMDE MATE Edition
    homer@localhost's password:
    [email protected] /tmp $

    That is one very useful trick.

    Copying files from one machine to another using the sftp command: http://www.securitronlinux.com/bejiitaswrath/how-to-copy-files-from-one-machine-to-another-using-ssh-and-the-sftp-command/.

    Remove unnecessary packages using the apt command.

    sudo apt autoremove

    Get information about any non-free packages installed on your system. Type sudo apt-get install vrms and then run it.

    homer@deusexmachina ~ $ vrms
               Non-free packages installed on deusexmachina
    atmel-firmware                      Firmware for Atmel at76c50x wireless networking chips.
    bluez-firmware                      Firmware for Bluetooth devices
    doom-wad-shareware                  Shareware game files for the 3D game Doom
    fglrx-control                       control panel for the non-free ATI/AMD RadeonHD displa
    fglrx-driver                        non-free ATI/AMD RadeonHD display driver
    fglrx-modules-dkms                  dkms module source for the non-free ATI/AMD RadeonHD d
    fglrx-source                        kernel module source for the non-free ATI/AMD RadeonHD
    firmware-atheros                    Binary firmware for Atheros wireless cards
    firmware-bnx2                       Binary firmware for Broadcom NetXtremeII
    firmware-bnx2x                      Binary firmware for Broadcom NetXtreme II 10Gb
    firmware-brcm80211                  Binary firmware for Broadcom 802.11 wireless cards
    firmware-intelwimax                 Binary firmware for Intel WiMAX Connection
    firmware-ipw2x00                    Binary firmware for Intel Pro Wireless 2100, 2200 and
    firmware-ivtv                       Binary firmware for iTVC15-family MPEG codecs (ivtv an
    firmware-iwlwifi                    Binary firmware for Intel Wireless cards
    firmware-libertas                   Binary firmware for Marvell Libertas 8xxx wireless car
    firmware-linux                      Binary firmware for various drivers in the Linux kerne
    firmware-linux-nonfree              Binary firmware for various drivers in the Linux kerne
    firmware-qlogic                     Binary firmware for QLogic IBA7220, QLA1xxx, ISP2xxx a
    firmware-ralink                     Binary firmware for Ralink wireless cards
    firmware-realtek                    Binary firmware for Realtek wired and wireless network
    libfglrx                            non-free ATI/AMD RadeonHD display driver (runtime libr
    nikto                               web server security scanner
    unrar                               Unarchiver for .rar files (non-free version)
    w64codecs                           win64 binary codecs
    zd1211-firmware                     Firmware images for the zd1211rw wireless driver
                Contrib packages installed on deusexmachina
    dosemu                              DOS Emulator for Linux
    game-data-packager                  Installer for game data files
    glx-alternative-fglrx               allows the selection of FGLRX as GLX provider
    glx-alternative-mesa                allows the selection of MESA as GLX provider
    glx-diversions                      prepare for using accelerated GLX implementations from
    nvidia-installer-cleanup            cleanup after driver installation with the nvidia-inst
    virtualbox-guest-dkms               x86 virtualization solution - guest addition module so
    virtualbox-guest-utils              x86 virtualization solution - non-X11 guest utilities
    virtualbox-guest-x11                x86 virtualization solution - X11 guest utilities
      26 non-free packages, 1.3% of 2035 installed packages.
      9 contrib packages, 0.4% of 2035 installed packages.

    Have a Cow say something in your terminal. Type sudo apt-get install cowsay and then execute it to see something cool.

    homer@deusexmachina ~ $ cowsay `/bin/date`
    < Tuesday 15 July 23:01:47 EST 2014 >
            \   ^__^
             \  (oo)\_______
                (__)\       )\/\
                    ||----w |
                    ||     ||

    Even more awesome Linux shell tricks.


  • John Cartwright 1:27 PM on July 3, 2014 Permalink | Reply
    Tags: , , , , shell   

    How to copy files from one machine to another using SSH and the sftp command. 

    The sftp command allows a user to retrieve files on a remote machine and save them on their computer.

    Use this command to access the files: sftp -P 443 [email protected]:/home/homer/Downloads/*.pdf I have my SSH server running on port 443, so I need to specify that port when using this command. I am using Cygwin on Windows Server 2012 R2, but this will work the same way on a Linux client.

    Administrator@WIN-EM8GK0ROU41 ~
    $ sftp -P 443 homer@*.pdf
    homer@'s password:
    Connected to
    Fetching /home/homer/Downloads/George_Martin_-_A_Game_of_Thrones.pdf to George_Martin_-_A_Game_of_Thrones.pdf
    /home/homer/Downloads/George_Martin_-_A_Game_of_Thrones.pdf                                                                            100% 5905KB   1.9MB/s   00:03
    Fetching /home/homer/Downloads/ISBSprogram6_16.pdf to ISBSprogram6_16.pdf
    /home/homer/Downloads/ISBSprogram6_16.pdf                                                                                              100% 1911KB   1.9MB/s   00:01
    Fetching /home/homer/Downloads/codenomicon-wp-smart-tv-fuzzing.pdf to codenomicon-wp-smart-tv-fuzzing.pdf

    This is a perfect way to access a file on your home server machine if you left it behind and you have SSH access.

    Administrator@WIN-EM8GK0ROU41 ~
    $ ls -hula
    total 12M
    drwxr-xr-x+ 1 Administrator None    0 Jul  3 13:19 .
    drwxrwxrwt+ 1 Administrator None    0 May 22 05:10 ..
    -rw-------  1 Administrator None 1.6K May 22 05:30 .bash_history
    -rwxr-xr-x  1 Administrator None 1.5K May 22 05:07 .bash_profile
    -rwxr-xr-x  1 Administrator None 6.0K May 22 05:07 .bashrc
    drwx------+ 1 Administrator None    0 May 22 05:29 .cache
    drwx------+ 1 Administrator None    0 May 22 05:29 .config
    -rwxr-xr-x  1 Administrator None 1.9K May 22 05:07 .inputrc
    drwx------+ 1 Administrator None    0 May 22 05:29 .local
    -rw-r--r--  1 Administrator None  116 May 22 05:19 .minttyrc
    -rwxr-xr-x  1 Administrator None 1.3K May 22 05:07 .profile
    drwx------+ 1 Administrator None    0 Jun  6 15:52 .ssh
    -rw-r--r--  1 Administrator None 3.9M Jul  3 13:19 codenomicon-wp-smart-tv-fuzzing.pdf
    drwxr-xr-x+ 1 Administrator None    0 May 23 11:19 Documents
    -rw-r--r--  1 Administrator None 5.8M Jul  3 13:19 George_Martin_-_A_Game_of_Thrones.pdf
    -rw-r--r--  1 Administrator None  12K May 22 12:23 index.html
    -rw-r--r--  1 Administrator None  12K May 22 12:27 index.html.1
    -rw-r--r--  1 Administrator None  12K May 23 11:13 index.html.2
    -rw-r--r--  1 Administrator None 1.9M Jul  3 13:19 ISBSprogram6_16.pdf
    -rw-r--r--  1 Administrator None   78 May 23 11:14 my.c
    -rw-r--r--  1 Administrator None 2.7K May 23 11:18 my.o

    Now I have the files on my local machine. This is one very useful trick to use when you are accessing an SSH server.

    • RoseHosting 1:23 AM on July 16, 2014 Permalink | Reply

      From my own personal experience I would recommend rsync (via ssh) over SFTP because rsync is much faster than SFTP, especially when copying many small files.

  • John Cartwright 6:24 PM on June 28, 2014 Permalink | Reply
    Tags: --rf, , , , , shell   

    How to use the touch command to create a file with an arbitrary filename. 

    The touch command ordinarily does not allow the user to create files with a filename like –rf, but if you want to really annoy someone then you may use this command to create one.

    [email protected]:~$ touch -- '--rf '

    And now you have a file named –rf.

    -rw-r--r--  1 homer homer    0 Jun 28 16:26 -rf

    This file cannot be easily deleted, the –rf is interpreted by rm as a command parameter.

    Therefore, this trick is necessary to delete this file.

    [email protected]:~/test$ rm -- -rf

    The -- parameter to rm signifies the end of command line parameters to the rm command. This allows you to delete this file. Below is another example.

    homer@debian:~/test$ ls -hula
    total 24K
    -rw-r--r--  1 homer homer    0 Jun 28 16:26 --
    drwxr-xr-x  2 homer homer 4.0K Jun 28 18:07 .
    drwxr-xr-x 24 homer homer 4.0K Jun 28 17:59 ..
    -rw-r--r--  1 homer homer  10K Jun 28 16:21 archive.tar
    -rw-r--r--  1 homer homer    0 Jun 28 16:17 --checkpoint=1
    -rw-r--r--  1 homer homer    0 Jun 28 16:17 --checkpoint-action=exec=sh 
    -rw-r--r--  1 homer homer    0 Jun 28 16:26 -f
    -rw-r--r--  1 homer homer    0 Jun 28 18:07 --rf 
    -rwsr-sr-x  1 homer homer   26 Jun 28 16:21 shell.sh

    Use this command to delete this file.

    [email protected]:~/test$ rm -- --rf

    This is very easy, you cannot create a file named . though. But give this a try yourself and see how you go!

Compose new post
Next post/Next comment
Previous post/Previous comment
Show/Hide comments
Go to top
Go to login
Show/Hide help
shift + esc