Browsing around...
News  News Links  Links Blog  Blog Italiano  Español 
02 - Linux useful commands


Before beginning, a quick review of some fundamental Linux aspects is useful.

Remember these commands:
  1. man [command]: it shows the guide/help for a specific command. Really useful if you forgot something.
  2. ls: it shows the content of a directory.
  3. mv [source] [destination]: If destination is a directory, moves the source (file or directory) to the destination directory. If source and destination are the same file, it renames the file.
  4. mkdir [name_dir]: it creates a directory.
  5. rm: it deletes a file.
  6. rmdir: it deletes a directory if it's empty.
  7. ps: it shows the processes being executed.
  8. find [name]: it searches for a file or a directory.
  9. sort [source]: it orders a source list (coming for example from a file) according to a criterion.
  10. grep [search] [source]: it shows on the monitor only the rows of the source containing the search word.
  11. head/tail [source]: the two commands show respectively the first 10 or last 10 rows of a file.
  12. chgrp / chown / chmod: the commands change the file attributes relative to group, owner and permissions respectively.
Input/Output redirection
In the Linux shell, as in almost every textual interfaces, the commands have a standard source and destination. For example the "sort" command visualizes the result of a sorting in the screen.

sort my_file.txt

Anyway, it can happen that you want to send the command output in another direction, for example to a file to save it. In this case you can use the redirection operators:
  1. Characters < and > (major and minor): they're used to take or send data from/to a file.
  2. Character | (pipe): used for chaining two or more commands; that is, it takes the output of one command and uses it as input for the next one.
Here there are two examples. If you want to save the result of the sort command to a file, you can write:

sort my_file.txt > my_file_sorted.txt

while if you want to sort the file my_file.txt and then visualize only the rows containing the word "er", you can write:

grep er my_file.txt | sort


Fatal error: Call to undefined function sqlite_open() in /membri/giacobbe85/include/ on line 324