Showing posts with label CommandLine. Show all posts
Showing posts with label CommandLine. Show all posts

Wednesday, May 13, 2015

Quake style drop down terminal for Gnome-Shell

Have you ever craved for Quake style drop down terminal?. In this post I'll share how to setup one on Gnome-shell desktop. Let's get started by installing the Drop down terminal extension from extensions.gnome.org. Let's test if it works. Press '~' to active the drop down terminal. Usually U assign 'Alt+F12' hotkeys on my computer. Here is the video of drop down terminal in action.

Let's customize the drop down terminal to launch in full screen mode. In the extension preferences I have set the terminal height to 800px. You have play around with transparency settings to show the underlying windows.

Gnome-shell Drop down terminal extension settings

Another good customization is to launch tmux. You can do this by setting custom command to run instead of launching the default shell.

That's it folks! Now you can enjoy the Quake style drop down terminals on Gnome-shell. Here is video of my setup.

Wednesday, November 12, 2008

Bash Path Security Gotcha!

The devil they say is in details, even the simple Bash path variable can open some security problems on your box. Every Bash documentation out there warns us not leave '.' in the path (it matches current directory). They however don't seems to mention that leaving a dangling ':' (colon) at the beginning or the end of Bash $PATH does create the same security vulnerability.

# Standard Bash $PATH $ echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games # Let's get evil, append a colon at the end $ export PATH="$PATH:" # Let's check the tainted Bash $PATH $ echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games: # Create Trojan application (of sorts) $ echo "echo foo"> app $ chmod +x app # Run the command and Viola! $ app foo

Wednesday, March 12, 2008

Grep : The Torment question

Here is a favorite question often posed to novice sysadmins. Ho, how they would sweat on this one!!. I was pleasantly surprised to see it find its way into Linux Journal's Tech tips. Darn good one Alessandro!.

Thursday, January 31, 2008

Raw Control Characters In Less pager

Less is my default terminal pager program. On GNU Debian Linux pager is just a symbolic link to your less or one of other available pager progams like more , most , lv etc..( run update-alternatives —list pager to find out alternative pager programs available on your computer). Lately some funny characters started showing up in my pager .

$ ls /tmp/Foo/ | pager

ESC[0mESC[0mFooBarESC[0m
ESC[0mMaster-fooESC[0m
ESC[m

Oops, That looks like the ANSI Escape Sequences commonly used for making a shell colourful, but our pager program less seems to have some trouble with it. Let’s try to correct this but using -R option which toggles this behaviour.

$ ls /tmp/Foo/ | pager -R
FooBar
Master-foo

Ok, that seems to fix it. Now let’s set it into our shell environment.You set the same using lesskey also.

LESS=”-R”; export LESS

Please note that using -r option may cause display problems , that’s why I use -R .

Wolfgang Friebel notes in Displaying more with less that ..

Syntax highlighting is only activated if the environment variable LESS is existing and contains the option -R or -r or less is called with one of these options. This guarantees, that instead of literal escape sequences colors are displayed. The detection of the -r/-R presence at runtime is rather dependent on the operating system and may not work in all cases. Putting the option in the LESS environment variable is guaranteed to work.By installing the perl module Proc::ProcessTable the OS dependence can be reduced as well.

Website file Uploads With lftp

Keeping your website updated is tedious job,especially when you have lot of files,which you edit quite often.And having to do the such work over ftp makes it worse.

In this article we’ll use a command line based file transfer program lftp(http://lftp.yar.ru/) written by Alexander .V. Lukyanov to do website file uploads.Though there are many other ftp clients,lftp is simpler to use,feature rich,can upload several files in parallel and it comes bundled up with most Gnu/Linux distributions. lftp is a powerful tool, its built-in mirror facility is suitable for keeping your website updated and secure by replicating permissions on the uploaded files.It checks for modified files by checking the file sizes and file modification times.

Using lftp on Command Line

Now you have a local directory on your computer where you keep all your website files(/home/joe/site_files).Let upload these files to your remote webserver directory using lftp on command line.First lets connect to your hosting service providers webserver with username and password.

$ lftp -u username ftp.hostingcompany.net
Password:

The lftp program will prompt for the password,type your secret password and you will be logged in.

Now issue the ‘lcd’ command to change directory to local directory where your all website files reside.

lftp username@ftp.hostingcompany.net:~> lcd /home/joe/site_files
lcd ok, local cwd=/home/joe/site_files

Now use the lftp mirror built-in’s reverse option (-R) of lftp to
upload all files local files into remote directory on the webserver.

lftp username@ftp.hostingcompany.net:~> mirror -R
Total: 12 directories, 36 files, 0 symlinks
Modified: 13 files, 0 symlinks

You can use “ mirror -R —only-newer “ command if you want only new files to uploaded.Once the upload is finished lftp will print out a report.Now you can end the connection by typing quit.

lftp username@ftp.hostingcompany.net:~> quit

Running lftp in a Script

Now that we have seen lftp in action.Let run all the commands from script instead.Luke Vanderfluit provides this nice little script.

lftp -u username,password ftp.hostingcompany.net <<EOF
cd / # remote directory on webserver
lcd /home/joe/site_files # local directory on your computer
mirror -R # Upload the files to remote directory
quit 0 # Drop the connection
EOF

Save all the commands in a file ‘upload_mysite’ and make it executable with ‘chmod +x upload_mysite’.Run the script by typing ‘./upload_mysite’ on the command line.As your username and password are stored it file,its a better not let anyone else to view it.Changing file permissions with ‘chmod go-rwx upload_mysite’.

Maintaining Multiple Websites

Running lftp from script is not a good idea if you have to maintain multiple sites.Instead you can use lftp’s ‘-f’ option.You can store settings of different websites into separate files.Suppose you have two websites site1 and site2.

The settings of the both the sites are stored in files ‘mysite1.lftp’ and ‘mysite2.lftp.

#####mysite1.lftp#######################
open ftp.myisp.net
user username password
lcd /usr/joe/site1_files
mirror -R
exit #########################################

#####mysite2.lftp#######################
open ftp.hostingcompany.com
user username password
lcd /usr/local_site_location
mirror -R
exit #########################################

To update site1, we will run lftp with ‘-f’ option.

$ lftp -f mysite1.lftp

And to update the next website.

$ lftp -f mysite2.lftp

Some other usefull features provided by ‘mirror’ built-in are the —parallel = N where in it will use N simultaneous connections to upload the files,this speeds up the upload considerably.If you want to exclude some files from being uploaded use (- x , – X) . And —delete to remove those files which are not present in local directory.

lftp can also be run as a cron job . Jani Reinikainen shows an interesting use of lftp to periodically mirroring a directory to a remote computer.

References

lftp manual page [http://lftp.yar.ru/lftp-man.html ]
lftp FAQ [http://lftp.yar.ru/FAQ ]
lftp Download page [http://lftp.yar.ru/get.html ]

Tuesday, January 29, 2008

Debian Dpatch How To

Tuxmaniac gets his hands dirty with dpatch and documents his experience in a easy to follow tutorial.

One review point that the packager comes across instantly is that “Do not change upstream code”. This is a Golden rule for packagers. Making these changes as patches in debian/ (for debian based distros ofcourse ;-) ) is highly recommended. One such tool for achieving this is DPATCH.

dpatch - just superb! (a short How to)

Sunday, January 27, 2008

Guide to Unix/Linux Commands

In October 2005 I contributed to the Guide to Unix/Linux commands wikibook. It is targeted at users who want to learn the shell commands by typing them on a Unix or gnu/Linux console. The wikibook is nowhere near complete but I guess it would be a good start if want to master the shell. For experienced users I request you to spare some time and contribute to this wikibook. If possible please try to adopt this documentation project.

The Guide to Unix/Linux Commands

The Guide to Unix/Linux command line is often considered difficult to learn. This book aims to help beginners by introducing various commands in lucid and simple language. Unlike most command references, this book is designed to be a self-study guide.

Contents

  • Getting Help man info apropos whatis makewhatis
  • File System Utilities ls mkdir cd pwd chroot cp mv rm touch df link ln unlink chown chmod mount
  • Finding Files find whereis which locate
  • File Viewing cat more less od head tail
  • File Editing pico nano zile vi joe emacs
  • File Compression gzip gunzip zcat gzcat tar pax bzip2 zip compress
  • File Analysingfile wc cksum stat
  • Multiuser Commandswho finger su
  • Self Information whoami groups id tty
  • System Information uptime uname dmesg free vmstat 50% top df hostname
  • Networking ifconf ifdown ifup
  • Process Managementnohup ps kill pgrep pidof killall
  • Devices fuser lsof fstat
  • Kernel Commands lsmod modprobe sysctl
  • Compress Commandstar cvf | tar xvf bunzip2
  • Miscellaneous sync echo cal date time mail clear PS1

Popular Posts