Article 49 - Ubuntu Useful Commands

This article goes over a list of commands that can be useful in the Ubuntu environment. You may want to bookmark it and use it as a reference.

Search all file contents in current directory for a particular substring.

Use grep: grep -i -n "<SEARCH_KEYWORDS>" *

Example: grep -i -n "burger" *

If you want to search all files recurisvely, then add the -r argument.

For example: grep -r -i -n "burger" *

Search all file names that contains substring.

Normally, you can use "find -name <SEARCH_KEYWORDS>" but it only returns certain subset of results that match the search keywords.

Instead, you want to pipe the results to grep.

For example: find . | grep <SEARCH_KEYWORDS>

This command is recursive, since find is functionally recursive.

Sudo echo and cat into file

Many users have been tricked by the sudo command for piping commands into restricted files, files that need higher prviledges such as the following command.

sudo dmesg > <restricted_file_path>

Instead, you need the command "sudo tee", which you can pipe results into. Use it like the following.

dmesg | sudo tee <restritected_file_path>

Pipe multiple text files.

A common use case is to pipe mulitple schema files into a database such as MYSQL.

For example, mysql_table.sql, mysql_keys.sql, and mysql_data.sql into the database.

For this purpose, you can use the command "cat <file1> ... <filen>".

Example: cat mysql_table.sql mysql_keys.sql mysql_data.sql | mysql -u root -p database

Show all exported variables

Just use the command "export", it is as simple as that

Comments (17)

Posted by anonymous - bookmaring service at Friday, March 15, 2013 6:38 AM

R4ujwE Very neat article. Really Great.

Posted by anonymous - what is ciprofloxacin at Friday, March 15, 2013 10:56 AM

Really appreciate you sharing this article.Much thanks again. Keep writing.

Posted by anonymous - buy generic viagra at Friday, March 15, 2013 12:35 PM

Really informative post.Thanks Again. Really Great.

Posted by anonymous - generic cialis online at Friday, March 15, 2013 2:14 PM

Thanks for sharing, this is a fantastic blog.Really looking forward to read more.

Posted by anonymous - Buy Levitra online uk at Friday, March 15, 2013 3:55 PM

Very neat blog post. Really Cool.

Post a comment

  • Name:
  • Post:
  • Challenge:

Register or login to post comments easier.


Vantasy World Copyright 2011 - 2023. Vantasy World is a project developed by Vantasy Online. Privacy Policy.