Linux Novice Very useful 20 commands __linux

Source: Internet
Author: User
Tags bz2 chmod create directory gpg parent directory time and date touch command android games
1. ls command

The LS command is the meaning of listing directory contents (list directory Contents). Running it is to list the contents of a folder, possibly a file or a folder.

root@tecmint:~# ls

android-games                     Music
Pictures                          public
Desktop                           tecmint.com
Documents                         tecmint-sync
Downloads                         Templates

The ls-l command lists the contents of the folder in detail mode (long listing fashion).

root@tecmint:~# ls-l Total

40588
drwxrwxr-x 2 ravisaive ravisaive     4096 may  8 01:06 Android Games
Drwxr-xr-x 2 ravisaive ravisaive     4096 could 10:50 Desktop
drwxr-xr-x 2 ravisaive ravisaive     4096 May 16 16:45 Documents
drwxr-xr-x 6 ravisaive ravisaive     4096 may 14:34 Downloads drwxr-xr-x
2 ravisaive ravisaive
  4096 Apr 20:50 Music
drwxr-xr-x 2 ravisaive ravisaive     4096 may  9 17:54 Pictures drwxrwxr-x
5 Ravi Saive ravisaive     4096 may  3 18:44 tecmint.com
drwxr-xr-x 2 ravisaive ravisaive     4096 Apr 20:50 Templ Ates

The "ls-a" command lists all the contents of the folder, including the "." The hidden file at the beginning.

root@tecmint:~# ls-a.                 . GnuPG. Dbus. goutputstream-pi5vvw mission-control. Adobe Deja-dup. Grsync -Mozilla themes. gstreamer-0.10 mtpaint thumbnails. Gtk-book Marks. Thunderbird. Hotshots. mysql_history. htaccess. Apport-ignore.xml.                    Iceauthority. Profile. Bash_history. Icons. bash_logout . Fbmessenger. JEdit. Pulse BASHRC liferea_1.8. Puls E-cookie. Xauthority. gconf.                       Xauthority.hghvww. Cache. gftp. Macromedia. Remmina. Cinnamon . gimp-2.8. ssh. xsession-errors. Compiz. Gnome Teamvi Ewer_linux.deb. Xsession-errors.old. config. gnome2. zoncolor 

Note: In Linux , files are "." The beginning is to hide the files, and each file, folder, device, or command is treated as a file. ls-l command output: D (represents the directory). rwxr-xr-x is the permissions of the file or directory to the owning user, the same group of users, and other users. The first ravisaive in the example above represents the file file belonging to the user ravisaive the second ravisaive in the example above represents that the file file belongs to the user group ravisaive 4096 represents a file size of 4096 bytes. May 8 01:06 represents the date and time the file was last modified. The last side is the file/folder name 2. lsblk command

"lsblk" is a list of block devices. In addition to RAM, the block device is displayed neatly in a standard tree-like output format.

root@tecmint:~# lsblk

NAME   maj:min RM   SIZE RO TYPE mountpoint
SDA      8:0    0 232.9G  0 disk 
├─sda1   8:1    0  46.6G  0/
├─sda2   8:2    0     1K 0 part 
├─sda5   8:5    0   190M  0 part/boot
├─sda6   8:6    0   3.7G  0 part [SWAP]
├─SDA7   8:7    0  93.1G  0 part/data
└─sda8   8:8    0  89.2G  0 part/personal
Sr0     11:0    1  1024M  0 rom


Thelsblk-lcommand displays a block device (not a tree format) in a list format.

root@tecmint:~# lsblk-l

NAME maj:min RM   SIZE RO TYPE mountpoint
SDA    8:0    0 232.9G  0 disk< C49/>SDA1   8:1    0  46.6G  0/
sda2   8:2    0     1K 0 part 
sda5   8:5    0   190M  0 part/boot
sda6   8:6    0   3.7G  0 part [SWAP]
sda7   8:7    0  93.1G  0 part/data
sda8   8:8    0  89.2G  0 part/personal
sr0   11:0    1  1024M  0 rom

Note:lsblk is the most useful and easy way to learn the name of a newly inserted USB device, especially if you are working on a disk/block device on a terminal.
3. md5sum command

"md5sum" is the computation and verification of MD5 information signatures. MD5 checksum (often called hashing) uses the integrity of files that match or verify files, because the files may change due to transmission errors, disk errors, or harmless interference.

root@tecmint:~# md5sum teamviewer_linux.deb 

47790ed345a7b7970fc1f2ac50c97002  teamviewer_linux.deb

Note: The user can use the official provided and md5sum to generate the signature information to detect whether the file has changed. Md5sum is not sha1sum safe, we will discuss this later. 4. DD Command

The "dd" command represents the transformation and copying of files. can be used to convert and copy files, most of the time is used to copy the ISO file (or any other file) to a USB device (or any other place), so can be used to make a USB launcher.

root@tecmint:~# DD If=/home/user/downloads/debian.iso OF=/DEV/SDB1 bs=512m; Sync

Note: In the above example, the USB device is SDB1 (you should use the lsblk command to verify it, otherwise you will rewrite your disk or system), please use the name of the disk carefully, avoid.

The DD command consumes a few seconds to minutes depending on the size and type of file and the read and write speed of the USB device. 5. uname command

The "uname" command is shorthand for UNIX name. Displays the machine name, operating system, and kernel details.

root@tecmint:~# uname-a

Linux tecmint 3.8.0-19-generic #30-ubuntu SMP Wed May 1 16:36:13 UTC 2013 i686 i686 i686 gnu/ Linux

Note: uname Displays the kernel category,uname-a displays details. The above output details the uname-a "Linux": The machine's kernel name "tecmint": The Machine's node name "3.8.0-19-generic": Kernel release version " #30-ubuntu SMP": Kernel version"i686": Processor architecture"gnu/linux": Operating system name 6. History command

The "history" command is a historical record. It shows the history of all the commands that have been executed in the terminal.

root@tecmint:~# history

 1  sudo add-apt-repository ppa:tualatrix/ppa
 2  sudo apt-get update
 3  sudo apt-get install ubuntu-tweak
 4  sudo add-apt-repository ppa:diesch/testing
 5  sudo apt-get Update
 6  sudo apt-get install indicator-privacy
 7  sudo add-apt-repository Ppa:atareao/atareao
 8  sudo apt-get update
 9  sudo apt-get install my-weather-indicator
 pwd one
 CD & & sudo cp-r unity/6/usr/share/unity/
 cd/usr/share/unity/icons/
 cd/usr/share/unity


NOTE: Hold down CTRL + R to search for commands that have been executed, which can be automatically filled when you write commands. 7. sudo command

The sudo(super user do) command allows authorized users to execute commands from Superuser or other users. specified by the security policy in the Sudoers list.

root@tecmint:~# sudo add-apt-repository Ppa:tualatrix/ppa

Note:sudo allows users to borrow power from superuser, whereas the "su" command actually allows users to log on as Superuser. So sudo is more secure than su .
sudo or su is not recommended for everyday use, because it can cause serious errors if you accidentally do something wrong, that's why it's popular in the Linux community:
8. mkdir command

The mkdir(make directory) command creates a new directory under a named path. However, if the directory already exists, it will return an error message "Cannot create a folder, the folder already exists" ("Cannot create folder, folders already exists")

root@tecmint:~# mkdir Tecmint


Note: The directory can only be created in a directory where the user has write permissions. mkdir: Unable to create directory ' Tecmint ' because the file already exists. (Don't be fooled by the file in the above output, you should remember what I said at the beginning-in Linux, files, folders, drives, commands, scripts are treated as files) 9. Touch Command

TheTouch command represents the update of the file's access and modification time to the current time. The Touch command creates it only when the file does not exist. If the file already exists, it updates the timestamp, but does not change the contents of the file.

root@tecmint:~# Touch Tecmintfile

Note: touch can be used to create files that do not exist in a directory where the user has write permissions. chmod Command

The "chmod" command is the mode bit that changes the file. chmod will change the file mode (permissions) for each given file, folder, script, and so on according to the required pattern.

There are 3 types of permissions in files (folders or other, for simplicity, we use files)

Read (R) =4
Write (w) =2
Execute (x) =1

So if you want to give the file read-only permission, set to ' 4 '; write-only permission, set the permission to ' 2 '; only execute permissions, set to 1; Read and Write permission is 4+2 = 6, and so on.

Now you need to set up 3 types of user and user group permissions. The first one is the owner, then the group the user is in, and finally the other user.

Rwxr-x--x   abc.sh

Here root is rwx ( Read and write and Execute permissions ),
The owning user group permission is r-x ( only Read and Execute permissions, no Write permissions),
For other user rights is-x(only execute permissions only)

To change its permissions, provide read, write, and execute permissions for the owner, the user's group, and other users.

root@tecmint:~# chmod 777 abc.sh

All three kinds have only read and write access

root@tecmint:~# chmod 666 abc.sh

Note: This command is one of the most useful commands for system administrators and users. In a multiuser environment or server, for a user, if a file is set inaccessible, the command can be resolved, and if the wrong permissions are set, access to the authorization is provided. chown command.

The "chown" command is to change the owner of the file and the group of users. Each file belongs to a user group and a user. In your directory, use "ls-l" and you will see things like this.

root@tecmint:~# ls-l 

drwxr-xr-x 3 server root 4096 May 11:14 Binary drwxr-xr-x 
2 server server 4096 May 13 09: Desktop

Here, the directory binary belongs to the user "server" and the user group "root" and the Directory "Desktop" belongs to the user "server" and the user group Server"

The "chown" command is used to change the ownership of a file, so the user and user group authorization is used only to manage and provide files.

root@tecmint:~# chown server:server Binary

drwxr-xr-x 3 Server server 4096 may ten 11:14 Binary drwxr-xr-x 
2 Serv Er server 4096 may 09:42 Desktop

Note: The files given by "chown" Change the ownership of users and groups to new owners or existing users or groups of users. Apt Order

The

Debian series is based on the " apt " command, and " apt " stands for advanced Package Tool. APT is an advanced Package manager developed for Debian Series Systems (Ubuntu,kubuntu, etc.) that, on the Gnu/linux system, automatically and intelligently searches, installs, upgrades, and resolves dependencies for packages.

root@tecmint:~# apt-get install MPlayer Reading Package lists ... Done building Dependency The Reading state information ...  Done the following package was automatically installed and are no longer required:java-wrappers use ' Apt-get autoremove '
To remove it. The following extra packages would be Installed:esound-common libaudiofile1 libesd0 libopenal-data libopenal1 libsvga1 L Ibvdpau1 Libxvidcore4 suggested Packages:pulseaudio-esound-compat libroar-compat2 nvidia-vdpau-driver Mplayer-doc Netselect fping The following NEW packages'll be Installed:esound-common libaudiofile1 libesd0 libopenal-
Data libopenal1 libsvga1 libvdpau1 libxvidcore4 mplayer 0 upgraded, 9 newly installed, 0 to remove and 8 not upgraded.
Need to get 3,567 KB of archives.
After this operation, 7,772 KB of additional disk space would be used. Do your want to continue [y/n]? Y 
root@tecmint:~# apt-get update Hit http://ppa.launchpad.net raring RELEASE.GPG Hit http://ppa.launchpad.net raring release.gpg Hit http://ppa.launchpad.net R Aring release.gpg Hit http://ppa.launchpad.net raring release.gpg get:1 http:/                                                   
/security.ubuntu.com raring-security RELEASE.GPG [933 B] Hit-http://in.archive.ubuntu.com raring RELEASE.GPG Hit http://ppa.launchpad.net raring release.gpg get:2 http://                                                  
security.ubuntu.com raring-security release [40.8 KB] Ign http://ppa.launchpad.net raring RELEASE.GPG                            
Get:3 http://in.archive.ubuntu.com raring-updates release.gpg [933 B] Hit http://ppa.launchpad.net raring RELEASE.GPG H It Http://in.archive.ubuNtu.com Raring-backports RELEASE.GPG 

Note: The above command causes the system to change as a whole, so the root password is required (the view prompt is "#" instead of "$"). Apt is more advanced and intelligent than the Yum command.

Apt-cache is used to search the package for the inclusion of MPlayer,apt-get to install, upgrade all installed packages to the latest version. tar command

The "tar" command is a tape archive (Tape Archive) that is useful for archiving and extracting files that are created.

root@tecmint:~# TAR-ZXVF abc.tar.gz (remember ' z ' represented. tar.gz)
root@tecmint:~# TAR-JXVF abc.tar.bz2 (Remember ' j ' stands for. tar.bz2)
root@tecmint:~# TAR-CVF archieve.tar.gz (. bz2)/PATH/TO/FOLDER/ABC

Note: "tar.gz" represents the use of gzip archiving, "bar.bz2" uses bZIP compression, which is better compressed but also slower. cal Command

Cal(calender), which is used to display the current month or month in the future or any previous year.

root@tecmint:~# Cal May 

2013        
Su Mo Tu We Th Fr Sa  
          1  2  3  4  
 5  6 7 8 9 10 11< c11/>12  
26 27 28 29 30 31 in the same.

Show the month that has passed, February 1835

root@tecmint:~# Cal 1835

   February 1835      
Su Mo Tu We Th Fr Sa  
 1  2  3  4  5  6  7  
 8  9 (  
22 23 24 25 26 27 28 in)

Show the next month, July 2145.

root@tecmint:~# Cal modified 2145

     July 2145        
Su Mo Tu We Th Fr Sa  
             1  2  3  
 4  5  6  7<  9 c36/>8  
25 26 27 28 29 30 31 in all of the same

Note: You do not need to adjust your calendar back to 50 without complex data calculations on the day you were born, or on which day your birthday will come, [because its smallest unit is the month, not the day]. Date Command

TheDate command prints the current date and time using standard output, or it can be set in depth.

root@tecmint:~# Date

Fri 14:13:29 IST 2013

root@tecmint:~# date--set= ' May 2013 13:57 '

Mon May 13:57:00 IST 2013

Note: This command is useful in scripts and is more perfect based on time and date scripts. and change the date and time in the terminal, make you more professional ... (Of course you need root permission to operate this because it's a system change) . Cat command

"Cat" represents the link (concatenation), connects two or more text files, or prints the contents of the file as standard output.

root@tecmint:~# cat a.txt b.txt c.txt d.txt abcd.txt
root@tecmint:~# cat Abcd.txt ...
.
Contents of file ABCD ...
CP Command

Copy "is copying. It will copy a file from one place to another place.

root@tecmint:~# cp/home/user/downloads Abc.tar.gz/home/user/desktop (return 0 when sucess)

Note: CPis the most commonly used command in a shell script, and it can use wildcards (described in the previous piece) to customize the copy of the desired file.

MV Command

TheMVcommand moves one place's files to another.

root@tecmint:~# mv/home/user/downloads Abc.tar.gz/home/user/desktop (return 0 when sucess)


Note: Themv command can be used with wildcard characters. MV needs to be used with caution, because mobile or unauthorized files can lead to security problems and possibly system crashes.

pwd Command

pwd"(print working directory) that displays the full path of the current working directory in the terminal.

root@tecmint:~# pwd 

/home/user/desktop

Note: This command will not be used frequently in scripts, but for beginners, it is definitely a lifesaver to lose a path in the terminal after a long connection to Nux.
CD Command

Finally, the frequently used "CD" command represents the Change directory. It changes the working directory in the terminal to perform, copy, move, read, write, etc.

root@tecmint:~# Cd/home/user/desktop

server@localhost:~$ pwd

/home/user/desktop


Note: When you switch directories in a terminal, theCD is on the table. "CD ~" Changes the working directory to the user's home directory, and is useful when the user finds that they have lost the path in the terminal. "cd ..." Switch from the current working directory to the parent directory (the current working directory).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.