Deprecated: Function get_magic_quotes_gpc() is deprecated in /srv/marcgottlieb.com/wp-includes/load.php on line 926

Notice: Trying to access array offset on value of type bool in /srv/marcgottlieb.com/wp-includes/theme.php on line 2360

Deprecated: Function get_magic_quotes_gpc() is deprecated in /srv/marcgottlieb.com/wp-includes/formatting.php on line 4826

Deprecated: Function get_magic_quotes_gpc() is deprecated in /srv/marcgottlieb.com/wp-includes/formatting.php on line 4826

Deprecated: Function get_magic_quotes_gpc() is deprecated in /srv/marcgottlieb.com/wp-includes/formatting.php on line 4826

Deprecated: Function get_magic_quotes_gpc() is deprecated in /srv/marcgottlieb.com/wp-includes/formatting.php on line 4826

Deprecated: Function get_magic_quotes_gpc() is deprecated in /srv/marcgottlieb.com/wp-includes/formatting.php on line 4826

Deprecated: Function get_magic_quotes_gpc() is deprecated in /srv/marcgottlieb.com/wp-includes/formatting.php on line 4826

Deprecated: Function get_magic_quotes_gpc() is deprecated in /srv/marcgottlieb.com/wp-includes/formatting.php on line 4826
September 2017 - Marc Gottlieb Consulting
Deprecated: Function get_magic_quotes_gpc() is deprecated in /srv/marcgottlieb.com/wp-includes/formatting.php on line 4826

Deprecated: Function get_magic_quotes_gpc() is deprecated in /srv/marcgottlieb.com/wp-includes/formatting.php on line 4826

Deprecated: Function get_magic_quotes_gpc() is deprecated in /srv/marcgottlieb.com/wp-includes/formatting.php on line 4826

Deprecated: Function get_magic_quotes_gpc() is deprecated in /srv/marcgottlieb.com/wp-includes/formatting.php on line 4826

Deprecated: Function get_magic_quotes_gpc() is deprecated in /srv/marcgottlieb.com/wp-includes/formatting.php on line 4826

Deprecated: Function get_magic_quotes_gpc() is deprecated in /srv/marcgottlieb.com/wp-includes/formatting.php on line 4826

Deprecated: Function get_magic_quotes_gpc() is deprecated in /srv/marcgottlieb.com/wp-includes/formatting.php on line 4826

Deprecated: Function get_magic_quotes_gpc() is deprecated in /srv/marcgottlieb.com/wp-includes/formatting.php on line 4826

Deprecated: Function get_magic_quotes_gpc() is deprecated in /srv/marcgottlieb.com/wp-includes/formatting.php on line 4826

Deprecated: Function get_magic_quotes_gpc() is deprecated in /srv/marcgottlieb.com/wp-includes/formatting.php on line 4826

Finding Files in the Command Line

Finding Files in the Command Line

http://ift.tt/2eOGmp9

Unfortunately in Linux, certainly Ubuntu, the default GUI file search is not the most useful way to find files.

With just a small amount of patience you can find files quickly and easily using the command line, and your options for this are really powerful if you want to learn a bit about it.

Locate

The easy, quick command is called “locate”. To use this command at the terminal you simply type:

$ locate -i searchstring

This will search for all files and directories with “searchstring” in the name, and -i means the search is not case sensitive (i.e. it will find searchstring, Searchstring, sEaRcHsTrInG, and so on).

The results are instantaneous because the system has created a database (also known as an index) to tell you where files are located. The only problem is that newly created or moved files may not be found correctly until the next database update, and you don’t have many options to choose from for your search.

Forcing locate to update the database/index is done with sudo updatedb and it doesn’t take a lot of time.

Example:

$ locate -i omgubuntu.desktop

Find

There is a much more powerful command available to you called “find”.

You can tell “find” where to look, what criteria to use in its search, and what actions to take once you have found what you are looking for.

The syntax for “find” is:

$ find <where to start searching> <search criteria> <actions to take>

If you don’t add any parameters, find will default to searching the current working directory (or “.“), uses no search criteria (defaults to showing all files), and -print (which, despite its name, displays, or “prints,” the results on screen) as the only action to take.

Two examples:

 $ sudo find / -type f -mmin -10

This example will find (starting at the root directory, or /, and recursively search subdirectories) all normal files (-type f means normal files, without this it will find normal files + special files + directories) which were modified less than ten minutes ago (-mmin -10), and then display the results for you.

This would be useful if you know you edited a file recently but don’t know where you put it, or have to find a log file for a program that crashed.

You can add sudo here because find does not search files/directories that the current user does not have permissions for, and it will return error messages if you aren’t a sudoer — just be careful!

 $ find ~ -iname "*new*" -exec mv -v {} /media/current-projects/ \;

This will find everything in your home directory (~) with a name, case insensitive (-iname), containing new (“*new*”) and execute (-exec) a move (mv) of the results ({}) to /media/current-projects/ ( \; is required by -exec to show the end of the command to be executed). So all your files will be moved to the same place. mv -v displays the results of the move command with (-v)erbose messages.

Another warning with -exec, though it is powerful, when used without care you can overwrite your whole home directory or whole disk – so be careful!

Catfish is a GUI Option

For those of you who simply can’t do without a GUI, you can find the program Catfish in the repositories — this enables you to run both locate and find from a graphical front-end, but it is very limited in options.

Think of Catfish as an equivalent to Windows Search. If you want the full power of find, you’ll need to run it from the command line, using the quick tips above.

Install Catfish from Ubuntu Software

What method do you prefer for file finding? Reply below and I’ll $ grep Nixie * it later. 😉

Linux

Linux

via OMG! Ubuntu! http://ift.tt/eCozVa

September 2, 2017 at 01:58PM

Instant +100% command line productivity boost

Instant +100% command line productivity boost

http://ift.tt/2gdxnRz

Being productive is fun.

There are a lot of fields to improve your productivity. Today I am going to share some command line tips and tricks to make your life easier.

TLDR

My full setup includes all the stuff discussed in this article and even more. Check it out: http://ift.tt/2vLdnbm

Shell

Using a good, helping, and the stable shell is the key to your command line productivity. While there are many choices, I prefer zsh coupled with oh-my-zsh. It is amazing for several reasons:

  • Autocomplete nearly everything
  • Tons of plugins
  • Really helping and customizable PROMPT

You can follow these steps to install this setup:

  1. Install zsh: http://ift.tt/1ggEpj2
  2. Install oh-my-zsh: http://ohmyz.sh/
  3. Choose plugins that might be useful for you: http://ift.tt/102JzCm

You may also want to tweak your settings to turn off case sensitive autocomplete. Or change how your history works.

That’s it. You will gain instant +50% productivity. Now hit tab as much as you can!

Theme

Choosing theme is quite important as well since you see it all the time. It has to be functional and pretty. I also prefer minimalistic themes, since it does not contain a lot of visual noise and unused information.

Your theme should show you:

  • current folder
  • current branch
  • current repository status: clean or dirty
  • error codes if any

I also prefer my theme to have new commands on a new line, so there is enough space to read and write it.

I personally use sobole. It looks pretty awesome. It has two modes.

Light:

sobole.zsh-theme

And dark:

sobole.zsh-theme

Get your another +15% boost. And an awesome-looking theme.

Syntax highlighting

For me, it is very important to have enough visual information from my shell to make right decisions. Like "does this command have any typos in its name" or "do I have paired scopes in this command"? And I really make tpyos all the time.

So, zsh-syntax-highlighting was a big finding for me. It comes with reasonable defaults, but you can change anything you want.

These steps brings us extra +5%.

Working with files

I travel inside my directories a lot. Like a lot. And I do all the things there:

  • navigating back and forwards
  • listing files and directories
  • printing files’ contents

I prefer to use z to navigate to the folders I have already been to. This tool is awesome. It uses ‘frecency’ method to turn your .dot TAB into ~/dev/shell/config/.dotfiles. Really nice!

When printing files you want usually to know several things:

  • file names
  • permissions
  • owner
  • git status of the file
  • modified date
  • size in human readable form

You also probably what to show hidden files to show up by default as well. So, I use exa as the replacement for standard ls. Why? Because it has a lot of stuff enabled by default:

exa

To print the file contents I use standard cat or if I want to see to proper syntax highlighting I use a custom alias:

# exa:
alias la="exa -abghl --git --color=automatic"

# `cat` with beautiful colors. requires: pip install -U Pygments
alias c='pygmentize -O style=borland -f console256 -g'

Now you have mastered the navigation. Get your +15% productivity boost.

Searching

When searching in a source code of your applications you don’t want to include folders like node_modules or bower_components into your results by default. You also want your search to be fast and smooth.

Here’s a good replacement for the built in search methods: the_silver_searcher.

It is written in pure C and uses a lot of smart logic to work fast.

Using ctrl + R for reverse search in history is very useful. But have you ever found yourself in a situation when I can quite remember a command? What if there were a tool that makes this search even greater enabling fuzzy searching and a nice UI?

There is such a tool, actually. It is called fzf:

fzf

It can be used to fuzzy-find anything, not just history. But it requires some configuration.

You are now a search ninja with +15% productivity bonus.

Conclusion

Following these simple steps, you can dramatically increase your command line productivity, like +100% (numbers are approximate).

There are other tools and hacks I will cover in the next articles.

Do you like reading about the latest trends in software development? Subscribe to our blog on Medium: http://ift.tt/2xvdcTk

Linux

Security

via Hacker News http://ift.tt/YV9WJO

August 31, 2017 at 09:25AM


Deprecated: Function get_magic_quotes_gpc() is deprecated in /srv/marcgottlieb.com/wp-includes/formatting.php on line 4826

Deprecated: Function get_magic_quotes_gpc() is deprecated in /srv/marcgottlieb.com/wp-includes/formatting.php on line 4826

Deprecated: Function get_magic_quotes_gpc() is deprecated in /srv/marcgottlieb.com/wp-includes/formatting.php on line 4826

Deprecated: Function get_magic_quotes_gpc() is deprecated in /srv/marcgottlieb.com/wp-includes/formatting.php on line 4826

Deprecated: Function get_magic_quotes_gpc() is deprecated in /srv/marcgottlieb.com/wp-includes/formatting.php on line 4826

Deprecated: Function get_magic_quotes_gpc() is deprecated in /srv/marcgottlieb.com/wp-includes/formatting.php on line 4826

Deprecated: Function get_magic_quotes_gpc() is deprecated in /srv/marcgottlieb.com/wp-includes/formatting.php on line 4826