There are three methods to find out Linux distribution and version:
Method 1: /etc/*-release
Issue following command to find out distro and version of installed Linux-
$ cat /etc/*-release
DISTRIB_ID=LinuxMint DISTRIB_RELEASE=16 DISTRIB_CODENAME=petra DISTRIB_DESCRIPTION="Linux Mint 16 Petra" NAME="Ubuntu" VERSION="13.10, Saucy Salamander" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 13.10" VERSION_ID="13.10" HOME_URL="http://www.ubuntu.com/" SUPPORT_URL="http://help.ubuntu.com/" BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
Method 2: lsb_release
lsb in lsb_release stands for Linux Standard Base
$ lsb_release -a
No LSB modules are available. Distributor ID: LinuxMint Description: Linux Mint 16 Petra Release: 16 Codename: petra
Method 3: /proc/version
This command returns kernel version and gcc version which was used to build it.
$ cat /proc/version
Linux version 3.11.0-12-generic (buildd@allspice) (gcc version 4.8.1 (Ubuntu/Linaro 4.8.1-10ubuntu7) ) #19-Ubuntu SMP Wed Oct 9 16:20:46 UTC 2013
Another way to find kernel version:
This command returns kernel version of currently installed Linux OS.
$ uname -r
$ uname -mrs
Linux 3.11.0-12-generic x86_64
rsync is a command in Linux which stands for remote sync. It is used for backing up the data. It synchronizes the directories and files from one location to another in a good way. The backup destination could be either on local or on remote server.
$ rsync options source destination
Case 1: Synchronize two directories in local server
use rsync -zvr command (z to enable compression, v for verbose, r for recursive)
$ rsync -zvr /var/opt/installation/inventory/ /root/temp
The above command does not preserves the timestamp.
Case 2: Preserve timestamps using rsync -a
The -a options preserves symbolic links, permissions, timestamp, owner and group.
$ rsync -azv /var/opt/installation/inventory/ /root/temp/
Case 3: Synchronize only a single file
Specify the file name to the rsync command
$ rsync -v /var/lib/rpm/Pubkeys /root/temp/
Case 4: Synchronize files Local->Remote
$ rsync -avz /root/temp/ firstname.lastname@example.org:/home/chankey/temp/
Case 5: Synchronize files Remote->Local
$ rsync -avz email@example.com:/var/lib/rpm /root/temp
Case 6: Select remote shell
$ rsync -avz -e ssh firstname.lastname@example.org:/var/lib/rpm /root/temp
rsync -e ssh => uses the ssh shell for remote sync
Case 7: Do not overwrite modified file at destination
If the file at the destination is modified and if we don’t want to change it back to the old one again then using rsync -u option.
$ rsync -avzu email@example.com:/var/lib/rpm /root/temp
Case 8: Synchronize only the directory Tree structure (not files)
use rsync -d option for this purpose.
$ rsync -v -d firstname.lastname@example.org:/var/lib/ .
Case 9: Do not create new file at destination, just update existing files
use --existing option
$ rsync -avz --existing email@example.com:/var/lib/rpm/ .
Case 10: Transfer the entire file
use rsync -W option
# rsync -avzW firstname.lastname@example.org:/var/lib/rpm/ /root/temp
You can use any of the method given below to view contents of a file in Linux. Let us say the file name is “filename”. Then you can view its content…
1. using cat command
2. using head command
3. using tail command
4. using pg command
5. using more command
6. using paste command
7. using grep command
8. using cut command
9. using while loop
10. using xargs command
11. using sed
12. using awk
13. using perl
If you know some more ways then share them in comments.
ffmpeg is a very fast video and audio converter that can also grab from a live audio/video source. It can also convert between arbitrary sample rates and resize video on the fly with a high quality polyphase filter.
Below are some tasks which you can perform using ffmpeg.
Getting information of a video
To get information of a video file use -i option as:
Making video from images
You can combine the images to make a video (like movie maker in windows) using ffmpeg as:
The above command will take all the images from the current directory (image1.jpg, image2.jpg, etc) and will join them to make a video file videofile.mpg.
Making images from video file
This is just opposite of the last step. This will take a video and will generate images from it.
Encoding video for iPod/iPhone
Source file: s_videofile.avi
Audio codec: aac
Audio bitrate: 128 kb/s
Video codec: mpeg4
Video bitrate: 1200 kb/s
Video size: 320×180
Generated video: f_videofile.mp4
Encoding video for PSP
Source : s_videofile.avi
Audio codec : aac
Audio bitrate : 32 kb/s
Video codec : xvid
Video bitrate : 1200 kb/s
Video size : 320×180
Generated video : f_videofile.mp4
Video to Audio
You can extract the audio from a video file and save it as mp3 format.
Source video : s_video.avi
Audio bitrate : 192kb/s
output format : mp3
Generated sound : soundfile.mp3
wav to mp3
avi to mpg
mpg to avi
avi to flv
avi to dv
avi to gif
Mixing video with a sound file
avi to mpeg (for dvd players)
ps 2000000000 is the maximum size for the output file in bits hence it is 2 GB here.
Compress avi to divx
Compress Ogg Theora to mpeg dvd
Compress avi to SVCD mpeg2
Compress avi to VCD mpeg2
sudo command is required when executing a command with some other user’s permission. Other user can either be root or else. Why we need to execute command with root’s permission? There are some commands that do some change in the system which are dangerous and can bring the system down, only root has such permissions.
WITH GREAT POWER COMES GREAT RESPONSIBILITY!
One can also switch user via su command and then execute the desired command but sudo is much more secure than su. Commands (along with arguments) executed with sudo are logged in a file. For Red Hat distros, /var/log/secure saves all the logs and for debian based, its /var/log/auth.log.
The file /etc/sudoers can be edited for configuring sudo and giving privileges to individual users or group of users.
For an individual user
Syntax for allowing an individual user (here Ayush) is:
ayush ALL=(ALL) ALL
“ayush” here is username of the user you want to allow
“ALL” specifies that sudo is accessible from all terminals
“(ALL)” specifies all users
“ALL” for all commands
For a group
Entry in sudoers file goes like:
%linuxstall ALL=(ALL) ALL
“linuxstall” can be replaced by the name of group.
Once the sudoers file is all set, you can now execute commands as root. For an instance, mount command can only be executed by root, but things go well with sudo.
There are some files that only root can save (say /etc/group) but having sudo in hand, it can be done as follows:
But, if you have opened the file as a normal user and wish to save but unable as only root can do that- sudo is your friend:
:w !sudo tee %
Above command will the save the file for you as a root even when you didn’t use it while opening. sudo just doesn’t mind!
If a user is not listed in sudoers file and tries to use sudo, admin will be notified by making a log entry and user will get following error:
<user> is not in the sudoers file. This incident will be reported.