`
isiqi
  • 浏览: 16491661 次
  • 性别: Icon_minigender_1
  • 来自: 济南
社区版块
存档分类
最新评论

25 Best Linux Commands

阅读更多

http://www.phpdevshell.org/node/51


25 Best Linux Commands

article_buygreen-linux-penguin.jpg

Source: As a Linux user you’ll come to learn and love certain commands. Remembering these commands is the toughest part. Some people use cheat-sheets some create scripts, and some just refer to website for their fix.

25) sshfs name@server:/path/to/folder /path/to/mount/point

Mount folder/filesystem through SSH

Install SSHFS from http://fuse.sourceforge.net/sshfs.html

Will allow you to mount a folder security over a network.

24) !!:gs/foo/bar

Runs previous command replacing foo by bar every time that foo appears

Very useful for rerunning a long command changing some arguments globally.

As opposed to ^foo^bar, which only replaces the first occurrence of foo, this one changes every occurrence.

23) mount | column -t

currently mounted filesystems in nice layout

Particularly useful if you’re mounting different drives, using the following command will allow you to see all the filesystems currently mounted on your computer and their respective specs with the added benefit of nice formatting.

22) <space>command

Execute a command without saving it in the history

Prepending one or more spaces to your command won’t be saved in history.

Useful for pr0n or passwords on the commandline.

21) ssh user@host cat /path/to/remotefile | diff /path/to/localfile -

Compare a remote file with a local file

Useful for checking if there are differences between local and remote files.

20) mount -t tmpfs tmpfs /mnt -o size=1024m

Mount a temporary ram partition

Makes a partition in ram which is useful if you need a temporary working space as read/write access is fast.

Be aware that anything saved in this partition will be gone after your computer is turned off.

19) dig +short txt <keyword>.wp.dg.cx

Query Wikipedia via console over DNS

Query Wikipedia by issuing a DNS query for a TXT record. The TXT record will also include a short URL to the complete corresponding Wikipedia entry.

18) netstat -tlnp

Lists all listening ports together with the PID of the associated process

The PID will only be printed if you’re holding a root equivalent ID.

17) dd if=/dev/dsp | ssh -c arcfour -C username@host dd of=/dev/dsp

output your microphone to a remote computer’s speaker

This will output the sound from your microphone port to the ssh target computer’s speaker port. The sound quality is very bad, so you will hear a lot of hissing.

16) echo “ls -l” | at midnight

Execute a command at a given time

This is an alternative to cron which allows a one-off task to be scheduled for a certain time.

15) curl -u user:pass -d status=”Tweeting from the shell” http://twitter.com/statuses/update.xml

Update twitter via curl

14) ssh -N -L2001:localhost:80 somemachine

start a tunnel from some machine’s port 80 to your local post 2001

now you can acces the website by going to http://localhost:2001/

13) reset

Salvage a borked terminal

If you bork your terminal by sending binary data to STDOUT or similar, you can get your terminal back using this command rather than killing and restarting the session. Note that you often won’t be able to see the characters as you type them.

12) ffmpeg -f x11grab -s wxga -r 25 -i :0.0 -sameq /tmp/out.mpg

Capture video of a linux desktop

11) > file.txt

Empty a file

For when you want to flush all content from a file without removing it (hat-tip to Marc Kilgus).

10) $ssh-copy-id user@host

Copy ssh keys to user@host to enable password-less ssh logins.

To generate the keys use the command ssh-keygen

9) ctrl-x e

Rapidly invoke an editor to write a long, complex, or tricky command

Next time you are using your shell, try typing ctrl-x e (that is holding control key press x and then e). The shell will take what you’ve written on the command line thus far and paste it into the editor specified by $EDITOR. Then you can edit at leisure using all the powerful macros and commands of vi, emacs, nano, or whatever.

8 ) !whatever:p

Check command history, but avoid running it

!whatever will search your command history and execute the first command that matches ‘whatever’. If you don’t feel safe doing this put :p on the end to print without executing. Recommended when running as superuser.

7) mtr google.com

mtr, better than traceroute and ping combined

mtr combines the functionality of the traceroute and ping programs in a single network diagnostic tool.

As mtr starts, it investigates the network connection between the host mtr runs on and HOSTNAME. by sending packets with purposly low TTLs. It continues to send packets with low TTL, noting the response time of the intervening routers. This allows mtr to print the response percentage and response times of the internet route to HOSTNAME. A sudden increase in packetloss or response time is often an indication of a bad (or simply over‐loaded) link.

6 ) cp filename{,.bak}

quickly backup or copy a file with bash

5) ^foo^bar

Runs previous command but replacing

Really useful for when you have a typo in a previous command. Also, arguments default to empty so if you accidentally run:

echo “no typozs”

you can correct it with

^z

4) cd -

change to the previous working directory

3):w !sudo tee %

Save a file you edited in vim without the needed permissions

I often forget to sudo before editing a file I don’t have write permissions on. When you come to save that file and get the infamous “E212: Can’t open file for writing”, just issue that vim command in order to save the file without the need to save it to a temp file and then copy it back again.

2) python -m SimpleHTTPServer

Serve current directory tree at http://$HOSTNAME:8000/

1) sudo !!

Run the last command as root

Useful when you forget to use sudo for a command. “!!” grabs the last run command.

Source...

分享到:
评论

相关推荐

    Linux for Developers: Jumpstart Your Linux Programming Skills

    Compare Linux languages to choose the best one for each task Write Bash scripts that interact with users or other shell features Program with Python and Perl: flow control, variables, and more ...

    CompTIA Linux+ Exam LX0-103 and Exam LX0-104, 3rd Edition

    Certification holders must recertify every five years, but LPI recommends recertifying every two years to stay fully up to date with new technologies and best practices. CompTIA Linux+ Study Guide ...

    Linux Essentials for Cybersecurity

    Master key commands, tools, and skills for securing Linux systems Troubleshoot common Linux security problems, one step at a time Protect user and group accounts with Pluggable Authentication Modules ...

    Linux and Unix Shell Programming

    With more and more systems being run under UNIX and Linux, the ability to program and customize the shell quickly and reliably to get the best out of any individual system is becoming a more and more ...

    Mastering Linux Shell Scripting

    Shell scripting is a quick method to prototype a complex application or a problem by automating tasks when working on Linux-based systems. Using both simple one-line commands and command sequences ...

    英文原版-Learn Linux in a Month of Lunches 1st Edition

    And best of all, Linux allows users access to different desktop interfaces and loads of software, almost all of it completely free.About the BookLearn Linux in a Month of Lunches shows you how to ...

    Linux for Developers

    * **Language Comparison:** Compares Linux languages to help developers choose the best language for each specific task. * **Decision-Making:** This comparison helps in selecting the most suitable ...

    Mastering Linux Shell Scripting.epub

    Shell scripting is a quick method to prototype a complex application or a problem by automating tasks when working on Linux-based systems. Using both simple one-line commands and command sequences ...

    Learn Linux in a Month of Lunches

    And best of all, Linux allows users access to different desktop interfaces and loads of software, almost all of it completely free. About the Book Learn Linux in a Month of Lunches shows you how to...

    Mastering Linux Shell Scripting.mobi

    Shell scripting is a quick method to prototype a complex application or a problem by automating tasks when working on Linux-based systems. Using both simple one-line commands and command sequences ...

    Mastering Linux Shell Scripting(PACKT,2015)

    Shell scripting is a quick method to prototype a complex application or a problem by automating tasks when working on Linux-based systems. Using both simple one-line commands and command sequences ...

    Apress Beginning Ubuntu Linux 3rd Edition Jun 2008.part2

    It is one of the computing industry’s best-kept secrets. I was bitten by the Linux bug in the mid-1990s. I was introduced to it by a friend who sold it to me as a kind of alternative to DOS. At that...

    Apress Beginning Ubuntu Linux 3rd Edition Jun 2008.part1

    It is one of the computing industry’s best-kept secrets. I was bitten by the Linux bug in the mid-1990s. I was introduced to it by a friend who sold it to me as a kind of alternative to DOS. At that...

    Mastering Linux Shell Scripting.pdf

    Shell scripting is a quick method to prototype a complex application or a problem by automating tasks when working on Linux-based systems. Using both simple one-line commands and command sequences ...

    Linux System Administrator Guide Version0.9

    **: Recommends the best filesystem based on the scenario. - **Creating a Filesystem**: Guides through creating a filesystem. - **Filesystem Block Size**: Discusses the impact of different block ...

    CentOS宝典.pdf

    Lead author Christopher Negus is the bestselling Linux author of such books as Fedora 10 and Red Hat Enterprise Linux Bible and Linux 2009 Edition Bible; he is also a member of the Red Hat Enterprise ...

    Classic Shell Scripting

    The ability to program and customize the shell quickly, reliably, and portably to get the best out of any individual system is an important skill for anyone operating and maintaining Unix or Linux ...

    torrent-search-cli:在命令行上搜索种子并在您的默认种子应用程序中打开它们

    [2]: Ubuntu Linux Toolbox 1000+ Commands for Ubuntu and Debian Power Users by Christopher Negus [2.49 MB / 6 files] 22/0 [3]: Debian 7- System Administration Best Practices, 2013 [PDF]~St

    Bash Quick Start Guide

    Bash and shell script programming is central to using Linux, but it has many peculiar properties that are hard to understand and unfamiliar to many programmers, with a lot of misleading and even risky...

Global site tag (gtag.js) - Google Analytics