Raspberry Pi Raspberry Practice notes-Common Linux commands

Source: Internet
Author: User
Tags secure copy

Filesystemlscd

Pwd

Mkdir

RMDIR

To remove the empty directories, use rmdir . So, for example, would rmdir oldDir remove the directory only oldDir if it is empty.

Rm

The command rm removes the specified file (or recursively from a directory if used with -r ). Be careful with this command:files deleted in the This is mostly gone for good!

Cp

Using cp makes a copy of a file and places it at the specified location (this is similar to copying and pasting). For example, cp ~/fileA /home/otherUser/ would copy the file from your home directory to that of the fileA user otherUser (assuming has Permissio N to copy it there). This command can either take FILE FILE ( cp fileA fileB ), FILE DIR ( cp fileA /directoryB/ ) or -r DIR DIR (which recursively copies the contents of directories) a s arguments.

Mv

mvThe command moves a file and places it at the specified location (so where cp performs a ' Copy-paste ', mv perfo RMS a ' cut-paste '). The usage is similar to cp . So mv ~/fileA /home/otherUser/ would move the file from your home directory to that of the fileA user OtherUser. This command can either take FILE FILE ( mv fileA fileB ), FILE DIR () mv fileA /directoryB/ or DIR DIR ( mv /directoryB /directoryC ) as arguments. This command was also useful as a method to rename files and directories after they ' ve been created.

TOUCH

The command touch sets the last modified Time-stamp of the specified file (s) or creates it if it does not already exist.

CAT

You can use cat to list the contents of file (s), e.g. 'll cat thisFile display the contents of thisFile . Can is used to list the contents of multiple files, i.e. would list the contents of all files in the current cat *.txt .txt dir Ectory.

HEAD

The head command displays the beginning of a file. Can -n is used with to specify the number of lines to show (by default ten), or with to specify the number of -c byt Es.

TAIL

headthe opposite of, tail displays the end of a file. The starting point in the file can is specified either through for -b a byte blocks, for -c bytes, or for -n Number of lines.

CHMOD

You would normally with the change of the chmod permissions for a file. The chmod command can use symbols u (user that owns the file), g (the Files group), and o (other users) and the Permissions r (read), w (write), and x (execute). Using would chmod u+x *filename* add execute permission for the owner of the file.

CHOWN

The chown command changes the user and/or group that owns a file. It normally needs to be run as root using sudo e.g. would change the owner to Pi and the sudo chown pi:root *filename* group to root.

Ssh

sshdenotes the secure shell. Connect to another computer using a encrypted network connection. for + details see SSH (Secure Shell)

Scp

The scp command copies a file from one computer to another using ssh . for + details see SCP (Secure copy)

Sudo

sudothe command enables you to run a command as a superuser, or another user. Use the for sudo -s a superuser shell. For more details see Root user/sudo

Dd

The dd command copies a file converting the file as specified. It is often used to copy an entire disk to a single file or back again. So, for example, would dd if=/dev/sdd of=backup.img create a backup image from the SD card or USB disk drive AT/DEV/SDD. Make sure to use the correct drive when copying a image to the SD card as it can overwrite the entire disk.

Df

Use to df display the disk space available and used on the mounted filesystems. Use to see the df -h output in a human-readable format using M for MBs rather than showing number of bytes.

UNZIP

The unzip command extracts the files from a compressed zip file.

TAR

Use the to tar store or extract files from a tape archive file. It can also reduce the space required by compressing the file similar to a zip file.

To create a compressed file, use to tar -cvzf *filename.tar.gz* *directory/* extract the contents of a file, usetar -xvzf *filename.tar.gz*

PIPES

A pipe allows the output from one command to being used as the input for another command. The pipe symbol is a vertical line | . For example, to only show the first ten entries of the ls command it can piped through the head commandls | head

TREE

Use the tree command to show a directory and all subdirectories and files indented as a tree structure.

&

Run a command & in the background with, freeing up the shell for future commands.

Wget

Download a file from the Web directly to the computer with wget . So would wget https://www.raspberrypi.org/documentation/linux/usage/commands.md download this file to your computer ascommands.md

CURL

Use to curl download or upload a file to/from a server. By default, it would output the file contents of the file to the screen.

Mans

Show the manual page for a file with man . To find out more, run to view the manual page of the Man man man command.

Searchgrep

Use the grep search inside files for certain search patterns. For example, would look in all the files in the current grep "search" *.txt directory ending with the. txt for the string search.

The grep command supports regular expressions which allows special letter combinations to is included in the search.

Awk

awkis a programming language useful for searching and manipulating text files.

FIND

The find command searches a directory and subdirectories for files matching certain patterns.

Whereis

Use to find the location of whereis a command. It looks through standard program locations until it finds the requested command.

Networkingping

The ping utility is usually used to check if communication can being made with another host. It can be used with the default settings by just specifying a hostname (e.g. ping raspberrypi.org ) or an IP address (e.g. ping 8.8.8.8 ). It can specify the number of packets to send with the -c flag.

Nmap

nmapis a network exploration and scanning tool. It can return port and OS information about a host or a range of hosts. Running just would display the options available as well as nmap example usage.

HOSTNAME

The hostname command displays the current hostname of the system. A privileged (super) user can set the hostname to a new one by supplying it as an argument (e.g. hostname new-host ).

IFCONFIG

Use to display the network configuration details for the interfaces in the current ifconfig system when run without any Argum Ents (i.e. ifconfig ). By supplying the command with the name of a interface (e.g. eth0 or lo ) you can then alter the Configuration:check t He manual page for more details.

Raspberry Pi Raspberry Practice notes-Common Linux commands

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.