Linux Command: Others [simple utility commands]

Here are some simple and useful commands-

file check type of file

Check the type of file using the ‘file’ command. You will get the file type and also some additional information based on the file type.

$ file abc_SVG_20kB.svg

abc_SVG_20kB.svg: SVG Scalable Vector Graphics image

$ file demo.mp4

demo.mp4: ISO Media, MP4 v2 [ISO 14496-14]

$ file first_conf.json

first_conf.json: JSON data

$ file sample1.gif

sample1.gif: GIF image data, version 89a, 1900 x 1267

$ file test_AVI_480_750kB.avi

test_AVI_480_750kB.avi: RIFF (little-endian) data, AVI, 480 x 270, 30.00 fps, video: H.264 H.264 X.264 or H.264, audio: (stereo, 48000 Hz)

$ file zip_201.zip

zip_201.zip: Zip archive data, at least v1.0 to extract, compression method=store
Bash

less read file content

The simplest way to read the file content is by using “less” command. This will give us the content we can read on the screen, and then we can go to the next content.

# use "less" and then the file name, like below
$ less first_conf.json

# you will see the content here
# Press Enter to read the next(or use options mentioned below)
# Use 'q' to quite
Bash

When you are presented with the next, you see a colon at the bottom of the screen. The output is continuous, and you need to know the shortcuts to navigate through the result.

Here are the options that we can use for the less command, after it shows the first set of content-

Command or KeyUsageAlternative key or command
spaceOne page forwardPage Down key
bOne page backwardPage Up key
Up arrowOne line up
Down arrowOne line downEnter
gGo to the start of the file1G
GGo to the end of the file
/search_termSearch for the “search_term”(use your actual search term here)
nGo to the next occurrence of the “search_term”, which was initiated by “/search_term”.
hHelp options
qQuit the “less” command output.

Leave a Comment


The reCAPTCHA verification period has expired. Please reload the page.