background preloader

Linux

Facebook Twitter

Understanding the bin, sbin, usr/bin , usr/sbin split. 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. It's just a quick introduction to get newbies going. 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: You Will Be Memorizing Things I'm warning you ahead of time that I'm going to make you memorize things right away. Note. 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.

For this, we need to tell tshark which interface to listen to and which traffic to capture. This is an example. 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 == 192.168.0.1" -r /tmp/capture.cap This example displays only IP packets that are issued by or in destination to the IP address 192.168.0.1.

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. It has so many it has to use both minuses and pluses. 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 Show all connections with -i # lsof -i Get only IPv6 traffic with -i 6 # lsof -i 6 # lsof -iTCP # lsof -i :22 # lsof +L1. 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. Linux and Open source Aliaser take control of your alias on Linux. Open Hardware Repository. Linux Manpages Online - man.cx manual pages. Javascript PC Emulator. \"Clone\" a list of installed packages from one Debian/Ubuntu Server to another. 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 daily.sh 20100819_202608 ++ find /root/scripts -iname '*.sh' -mtime -1 + for SCRIPT in '`find /root/scripts -iname '\''*.sh'\'' -mtime -1`' + '[' -f /root/scripts/daily.sh ']' + cp /root/scripts/daily.sh /home/daily_20100819_202608/ + set +x /root/scripts/daily.sh is backed up to /home/daily_20100819_202608 The “-v” option prints shell input lines as they are read.

. #! Tagged as: debug. Joshua Levy's answer to What are some lesser known but useful Unix commands. Linux: What are some time-saving tips that every Linux user should know. 10 examples of using find command in UNIX. How to run last executed find command in Unix – Example 1 ! Find will repeat the last find command executed. It saves lot of time if you re searching for something and you need to execute same command again and again.

In fact "! " can be used with any command to invoke previous run of that command. javin@testenv1 ~/java : ! How to find files which has been modified less than one day, minute or hour in Unix: find -mtime is used to search files based upon modification time. Javin@testenv1 ~/java : find . Javin@testenv1 ~/java : find . Javin@testenv1 ~/java : find . In this example since we have only modified StockTrading.java some time back it has shown on find –mtime -1, rest of files are not touched today so they are appearing as modified more than 1 day while there is no file which has been modified exactly one day. How to find all the files and directories which holds the 777 permission in Unix box – Exmaple 3 find –perm option is used to find files based upon permissions.

Find . Find . My Extravagant Zsh Prompt. I spend a lot of time in a Terminal window at a command line. Up until about a month ago I was using bash for my shell. I decided to try switching to Zsh after hearing a lot of good things about it and I’m very happy with the change. bash: A few days ago I tweeted my current Zsh prompt and the general response was: “Cool, but how did you do it?” I promised to write more about it when I got some free time, and it looks like that time is now. tweeted: One quick note: This entry is about the prompt that I find useful. Twitter: Another quick note: I’ve customized the colors of my Terminal. Monokai: Why Should You Care? Many people use the command line every day and never bother to customize their prompts.

This Entry is About Zsh Prompts #! Gustavo Duarte.

Embarqué