background preloader

Bash Shortcuts For Maximum Productivity

Bash Shortcuts For Maximum Productivity
It may or may not surprise you to know that the bash shell has a very rich array of convenient shortcuts that can make your life, working with the command line, a whole lot easier. This ability to edit the command line using shortcuts is provided by the GNU Readline library. This library is used by many other *nix application besides bash, so learning some of these shortcuts will not only allow you to zip around bash commands with absurd ease :), but can also make you more proficient in using a variety of other *nix applications that use Readline. I don’t want to get into Readline too deeply so I’ll just mention one more thing. By default Readline uses emacs key bindings, although it can be configured to use the vi editing mode, I however prefer to learn the default behavior of most applications (I find it makes my life easier not having to constantly customize stuff). Command Editing Shortcuts Command Recall Shortcuts Command Control Shortcuts Bash Bang (!) !! Image by djhsilver Related Related:  shell

lsof lsof is the sysadmin/security über-tool. I use it most for getting network connection related information from a system, but that’s just the beginning for this powerful and too-little-known application. The tool is aptly called lsof because it “lists open files“. And remember, in UNIX just about everything (including a network socket) is a file. Interestingly, lsof is also the Linux/Unix command with the most switches. usage: [-? As you can see, lsof has a truly staggering number of options. For me, lsof replaces both netstat and ps entirely. Key Options It’s important to understand a few key things about how lsof works. Here are a few others like that to keep in mind: default : without options, lsof lists all open files for active processesgrouping : it’s possible to group options, e.g. Getting Information About the Network As I said, one of my main usecases for lsof is getting information about how my system is interacting with the network. Show all connections with -i # lsof -i # lsof -i 6

Vim Cheat Sheat for Programmers by Michael Pohoreski Update: Version 2.0 is up! There are now 4 versions to chose from: (If you are wondering what the differences are between the screen and print: the screen has less color variations, and no gradients to make it easier to read.) One designed for on-screen reading: PDF (Excel 2011 source),One designed for hard-copy reading: PDF (Excel 2011 source),One designed for monochrome printing: PDF (Excel 2011 source), andOne designed for Red/Green color bindness -- a "Blue" theme PDF (Excel 2011 source). The color coded Legend / Keys helps provide guidance for your experience level. Green = Essential Yellow = Basic Orange / Blue = Advanced Red = Expert If you don't like this version (I'd love to hear why) try these, you may find them more to your liking... Thanks to all the redditors for the feedback! The on-screen 150 DPI .png version is shown... The color hard-copy 300 DPI .png version: The monochrome hard-copy 300 DPI .png version: An color blind hard-copy 150 DPI .png version: === Vim Rants ===

How to Install Sublime Text 3 in Ubuntu 14.04 Trusty This simple tutorial shows you how to install the Sublime Text 3 in Ubuntu 14.04 Trusty LTS via PPA repository. Sublime Text is a popular text and source code editor somewhat similar to TextMate, available for Windows, Linux, Mac OS X. The Sublime Text 3 is currently in beta. Install Sublime Text 3: To get started, press Ctrl+Alt+T on your keyboard to open a terminal window. sudo add-apt-repository -y ppa:webupd8team/sublime-text-3 Type in your password when prompts and then you’ll get this PPA (Personal Package Archive) into your system. NOTE: you’ll see nothing when typing passwords in Linux terminal, just type in mind and hit enter to get pass. After added the PPA, run commands to install the script: sudo apt-get update; sudo apt-get install -y sublime-text-installer Once installed, open the editor from Unity Dash or Menu. To disable new version notifications, add the following to your User Preferences file (Preferences > Settings – User): “update_check”: false

Linux Manpages Online - manual pages Linux Tutorial - Managing Group Access on Linux and UNIX Group File, Directory and Device permissions: chmod Set file, directory and device permissions: File, directory and device permissions can be set to allow or deny access to members of their own group or all others. Modification of file, directory and device access is achieved with the chmod command. The permissions can be assigned in octal notation or in the more easily recognized character format where the command form is: chmod [ugoa][+-=][rwxXst] fileORdirectoryName Note: Other file systems can be mounted by Linux which support more file and directory options. Examples: Grant read access (r) to a file to all members of your group (g): chmod g+r file-name Grant read access to a directory to all members your group: chmod g+rx directory-name Note that "execute" permission is required in order to read a directory. View file, directory and device permissions: Permissions may be viewed by issuing the command: ls -l file-name File can be written by youself and members of the group. Format:

SSH login without password Your aim You want to use Linux and OpenSSH to automate your tasks. Therefore you need an automatic login from host A / user a to Host B / user b. How to do it First log in on A as user a and generate a pair of authentication keys. a@A:~> ssh-keygen -t rsa Generating public/private rsa key pair. Now use ssh to create a directory ~/.ssh as user b on B. a@A:~> ssh b@B mkdir -p .ssh b@B's password: Finally append a's new public key to b@B:.ssh/authorized_keys and enter b's password one last time: a@A:~> cat .ssh/ | ssh b@B 'cat >> .ssh/authorized_keys' b@B's password: From now on you can log into B as b from A as a without password: a@A:~> ssh b@B A note from one of our readers: Depending on your version of SSH you might also have to do the following changes: Put the public key in .ssh/authorized_keys2Change the permissions of .ssh to 700Change the permissions of .ssh/authorized_keys2 to 640 Keywords: ssh openssh password Author: Mathias Kettner

Tshark examples: howto capture and dissect network traffic - Vimperator This page contains a collection of useful examples for using tshark, the network traffic capture and analysis tool. Network Traffic Capture tshark can be used to dump network traffic into capture files for later processing. tshark -f "udp port 1812" -i eth0 -w /tmp/capture.cap The -f flag is used to specify a network capture filter (more on filters later). Network capture rules Network capture rules or filters, specified by the -f option allows you to tell tshark which packets should be captured. Packet display rules Packet display rules or filters as their name imply, allow you to control which packets are displayed by tshark when performing live network capture or when tshark is reading a capture file. tshark -R "ip.addr ==" -r /tmp/capture.cap This example displays only IP packets that are issued by or in destination to the IP address The filter expression can be a logical combination of other filter expressions. Network Traffic Dissection

bash - How to create script with auto-complete? Find Errors in Your Bash Scripts with Debug Options You do not have to debug the whole script, you can just debug the sections giving you the most difficulties. In this example, “set -x” and “set +x” encompass the section that you want to debug. The output shows how this section is sent to screen while the rest of the script functions normally. #!/bin/bash TIMESTAMP=`date +%Y%m%d_%H%M%S`; echo $TIMESTAMP DIR=/home/daily_$TIMESTAMP; mkdir $DIR set -x for SCRIPT in `find /root/scripts -iname '*.sh' -mtime -1` do if [ -f $SCRIPT ] then cp $SCRIPT $DIR/ set +x echo "$SCRIPT is backed up to $DIR" fi done sh 20100819_202608 ++ find /root/scripts -iname '*.sh' -mtime -1 + for SCRIPT in '`find /root/scripts -iname '\''*.sh'\'' -mtime -1`' + '[' -f /root/scripts/ ']' + cp /root/scripts/ /home/daily_20100819_202608/ + set +x /root/scripts/ is backed up to /home/daily_20100819_202608 The “-v” option prints shell input lines as they are read. #! Tagged as: debug

shell - Check if a program exists from a bash script The Command Line Crash Course Controlling Your Computer From The Terminal - Vimperator Contents Preface I wrote this book really quickly as a way to bootstrap students for my other books. Many students don't know how to use the basics of the command line interface, and it was getting in the way of their learning. This book is designed to be something they can complete in about a day to a week and then get enough skill at the command line to graduate to other books. This book isn't a book about master wizardry system administration. Introduction: Shut Up And Shell This book is a crash course in using the command line to make your computer perform tasks. The only piece of advice I am going to give you is this: Shut up and type all of this in. Sorry to be mean, but that's what you have to do. You are not going to destroy your computer. Why? How To Use This Book The best way to use this book is to do the following: Just keep going through this process of doing an exercise, writing down questions you have, then going back through and answering the questions you can. License I (Zed A.

how to use ssh to run shell script on a remote machine?