Menu

Ubuntu Archive

Search for files using find

The find command is used in Linux to search for files in the directory tree starting from the location specified. It searches your filesystem live, which causes the command to run slower than the locate command. The syntax of the command is: find PATH EXPRESSION The expression is a way of specifying what you want to find. You can

Search for files using locate

The locate command searches a database of filenames in Linux. Unlike the find command, which can find files by permissions, owner, file size, etc, the locate command finds files only by their name.  This command does not search your system live. Instead, it has its own database that it usually updated once a night or once a week. This means that locate may

Split the output of a program

The tee command splits the output of a program, so that it can be both displayed on the screen and saved in a file. This command is usually used when you want the output of the program to be both stored and displayed at the terminal. For example, if we want to display the output of the ls command on

Display first lines of a text file

The head command displays, by default, the first 10 lines of a text file in Linux. This command is often used to get an idea of the kind of text file you’re looking at; the first 10 lines are usually enough to determine what a file is. Example: As with tail, you can specify the number of lines

Display last lines of a text file

The tail command displays, by default, the last 10 lines of a text file in Linux. This command can be very useful when examining recent activity in log files. Example: In the picture above you can see that the last 10 lines of the /tmp/example.txt file were displayed. The tail command can be used with various options. For example, if you would like to

whereis command

The whereis command in Linux is used to locate the binary, source, and manual page files for a command. This command searches for files in a restricted set of locations (binary file directories, man page directories, and library directories). It is usually used to find executables of a program, its man pages and configuration files. The syntax of the command

Determine file type in Linux or Mac OS X

To determine the file type in Linux, we can use the file command. This command runs three sets of tests: the filesystem test, magic number test, and language test. The first test that succeeds causes the file type to be printed. For example, if a file is a text file, it will be recognized as ASCII text. Here are a couple of

Count lines in a file

wc (short for word count) is a command in Linux that displays a count of lines (newline characters, to be precise), words, and bytes for each file you specify. The program prints these three numbers for each file you specify. For example, to find out how many lines, words and bytes random-text.txt has, we can use the following command:

Sort lines of a text file

The sort command is used to sort the lines of a text file in Linux. You can provide several command line options for sorting data in a text file. Here is an example file: To sort the file in alphabetical order, we can use the sort command without any options: To sort in reverse, we can use the -r option: To

How to check OpenSSH version on Linux?

Using Linux – let’s open terminal and enter ssh -v localhost or ssh -V to check the OpenSSH version which is currently installed. __________________________________________________________ $ ssh -v localhost OpenSSH_7.9p1, LibreSSL 2.7.3 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 48: Applying options for * debug1: Connecting to localhost port 22. ssh: connect to host localhost port 22: Connection refused