Merge remote-tracking branch 'LCTT/master'

This commit is contained in:
Xingyu.Wang 2019-03-14 10:10:29 +08:00
commit a69adaa5f4
15 changed files with 1608 additions and 128 deletions

View File

@ -1,8 +1,8 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-10616-1.html)
[#]: subject: (How to use sudo access in winSCP)
[#]: via: (https://kerneltalks.com/tools/how-to-use-sudo-access-in-winscp/)
[#]: author: (kerneltalks https://kerneltalks.com)
@ -10,9 +10,11 @@
如何在 winSCP 中使用 sudo
======
用截图了解如何在 winSCP 中使用 sudo
> 用截图了解如何在 winSCP 中使用 sudo
![How to use sudo access in winSCP][1]sudo access in winSCP
![How to use sudo access in winSCP][1]
*sudo access in winSCP*
首先你需要检查你尝试使用 winSCP 连接的 sftp 服务器的二进制文件的位置。
@ -28,18 +30,20 @@ Subsystem sftp /usr/libexec/openssh/sftp-server
打开 winSCP 并单击“高级”按钮打开高级设置。
![winSCP advance settings][2]
winSCP 高级设置
它将打开如下高级设置窗口。在左侧面板上选择`环境`下的 `SFTP`。你会在右侧看到选项。
*winSCP 高级设置*
它将打开如下高级设置窗口。在左侧面板上选择“Environment”下的 “SFTP”。你会在右侧看到选项。
现在,使用命令 `sudo su -c` 在这里添加 SFTP 服务器值,如下截图所示:
![SFTP server setting in winSCP][3]
winSCP 中的 SFTP 服务器设置
所以我们在设置中添加了 `sudo su -c /usr/libexec/openssh/sftp-server`。单击“确定”并像平常一样连接到服务器。
*winSCP 中的 SFTP 服务器设置*
连接之后,你将可以从需要 sudo 权限的目录传输文件了。
所以我们在设置中添加了 `sudo su -c /usr/libexec/openssh/sftp-server`。单击“Ok”并像平常一样连接到服务器。
连接之后,你将可以从你以前需要 sudo 权限的目录传输文件了。
完成了!你已经使用 winSCP 使用 sudo 登录服务器了。
@ -50,7 +54,7 @@ via: https://kerneltalks.com/tools/how-to-use-sudo-access-in-winscp/
作者:[kerneltalks][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -0,0 +1,283 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Build a game framework with Python using the module Pygame)
[#]: via: (https://opensource.com/article/17/12/game-framework-python)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
Build a game framework with Python using the module Pygame
======
The first part of this series explored Python by creating a simple dice game. Now it's time to make your own game from scratch.
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/python2-header.png?itok=tEvOVo4A)
In my [first article in this series][1], I explained how to use Python to create a simple, text-based dice game. This time, I'll demonstrate how to use the Python module Pygame to create a graphical game. It will take several articles to get a game that actually does anything, but by the end of the series, you will have a better understanding of how to find and learn new Python modules and how to build an application from the ground up.
Before you start, you must install [Pygame][2].
### Installing new Python modules
There are several ways to install Python modules, but the two most common are:
* From your distribution's software repository
* Using the Python package manager, pip
Both methods work well, and each has its own set of advantages. If you're developing on Linux or BSD, leveraging your distribution's software repository ensures automated and timely updates.
However, using Python's built-in package manager gives you control over when modules are updated. Also, it is not OS-specific, meaning you can use it even when you're not on your usual development machine. Another advantage of pip is that it allows local installs of modules, which is helpful if you don't have administrative rights to a computer you're using.
### Using pip
If you have both Python and Python3 installed on your system, the command you want to use is probably `pip3`, which differentiates it from Python 2.x's `pip` command. If you're unsure, try `pip3` first.
The `pip` command works a lot like most Linux package managers. You can search for Python modules with `search`, then install them with `install`. If you don't have permission to install software on the computer you're using, you can use the `--user` option to just install the module into your home directory.
```
$ pip3 search pygame
[...]
Pygame (1.9.3)                 - Python Game Development
sge-pygame (1.5)               - A 2-D game engine for Python
pygame_camera (0.1.1)          - A Camera lib for PyGame
pygame_cffi (0.2.1)            - A cffi-based SDL wrapper that copies the pygame API.
[...]
$ pip3 install Pygame --user
```
Pygame is a Python module, which means that it's just a set of libraries that can be used in your Python programs. In other words, it's not a program that you launch, like [IDLE][3] or [Ninja-IDE][4] are.
### Getting started with Pygame
A video game needs a setting; a world in which it takes place. In Python, there are two different ways to create your setting:
* Set a background color
* Set a background image
Your background is only an image or a color. Your video game characters can't interact with things in the background, so don't put anything too important back there. It's just set dressing.
### Setting up your Pygame script
To start a new Pygame project, create a folder on your computer. All your game files go into this directory. It's vitally important that you keep all the files needed to run your game inside of your project folder.
![](https://opensource.com/sites/default/files/u128651/project.jpg)
A Python script starts with the file type, your name, and the license you want to use. Use an open source license so your friends can improve your game and share their changes with you:
```
#!/usr/bin/env python3
# by Seth Kenlon
## GPLv3
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
```
Then you tell Python what modules you want to use. Some of the modules are common Python libraries, and of course, you want to include the one you just installed, Pygame.
```
import pygame  # load pygame keywords
import sys     # let  python use your file system
import os      # help python identify your OS
```
Since you'll be working a lot with this script file, it helps to make sections within the file so you know where to put stuff. You do this with block comments, which are comments that are visible only when looking at your source code. Create three blocks in your code.
```
'''
Objects
'''
# put Python classes and functions here
'''
Setup
'''
# put run-once code here
'''
Main Loop
'''
# put game loop here
```
Next, set the window size for your game. Keep in mind that not everyone has a big computer screen, so it's best to use a screen size that fits on most people's computers.
There is a way to toggle full-screen mode, the way many modern video games do, but since you're just starting out, keep it simple and just set one size.
```
'''
Setup
'''
worldx = 960
worldy = 720
```
The Pygame engine requires some basic setup before you can use it in a script. You must set the frame rate, start its internal clock, and start (`init`) Pygame.
```
fps   = 40  # frame rate
ani   = 4   # animation cycles
clock = pygame.time.Clock()
pygame.init()
```
Now you can set your background.
### Setting the background
Before you continue, open a graphics application and create a background for your game world. Save it as `stage.png` inside a folder called `images` in your project directory.
There are several free graphics applications you can use.
* [Krita][5] is a professional-level paint materials emulator that can be used to create beautiful images. If you're very interested in creating art for video games, you can even purchase a series of online [game art tutorials][6].
* [Pinta][7] is a basic, easy to learn paint application.
* [Inkscape][8] is a vector graphics application. Use it to draw with shapes, lines, splines, and Bézier curves.
Your graphic doesn't have to be complex, and you can always go back and change it later. Once you have it, add this code in the setup section of your file:
```
world    = pygame.display.set_mode([worldx,worldy])
backdrop = pygame.image.load(os.path.join('images','stage.png').convert())
backdropbox = world.get_rect()
```
If you're just going to fill the background of your game world with a color, all you need is:
```
world = pygame.display.set_mode([worldx,worldy])
```
You also must define a color to use. In your setup section, create some color definitions using values for red, green, and blue (RGB).
```
'''
Setup
'''
BLUE  = (25,25,200)
BLACK = (23,23,23 )
WHITE = (254,254,254)
```
At this point, you could theoretically start your game. The problem is, it would only last for a millisecond.
To prove this, save your file as `your-name_game.py` (replace `your-name` with your actual name). Then launch your game.
If you are using IDLE, run your game by selecting `Run Module` from the Run menu.
If you are using Ninja, click the `Run file` button in the left button bar.
![](https://opensource.com/sites/default/files/u128651/ninja_run_0.png)
You can also run a Python script straight from a Unix terminal or a Windows command prompt.
```
$ python3 ./your-name_game.py
```
If you're using Windows, use this command:
```
py.exe your-name_game.py
```
However you launch it, don't expect much, because your game only lasts a few milliseconds right now. You can fix that in the next section.
### Looping
Unless told otherwise, a Python script runs once and only once. Computers are very fast these days, so your Python script runs in less than a second.
To force your game to stay open and active long enough for someone to see it (let alone play it), use a `while` loop. To make your game remain open, you can set a variable to some value, then tell a `while` loop to keep looping for as long as the variable remains unchanged.
This is often called a "main loop," and you can use the term `main` as your variable. Add this anywhere in your setup section:
```
main = True
```
During the main loop, use Pygame keywords to detect if keys on the keyboard have been pressed or released. Add this to your main loop section:
```
'''
Main loop
'''
while main == True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit(); sys.exit()
            main = False
        if event.type == pygame.KEYDOWN:
            if event.key == ord('q'):
                pygame.quit()
                sys.exit()
                main = False
```
Also in your main loop, refresh your world's background.
If you are using an image for the background:
```
world.blit(backdrop, backdropbox)
```
If you are using a color for the background:
```
world.fill(BLUE)
```
Finally, tell Pygame to refresh everything on the screen and advance the game's internal clock.
```
    pygame.display.flip()
    clock.tick(fps)
```
Save your file, and run it again to see the most boring game ever created.
To quit the game, press `q` on your keyboard.
In the [next article][9] of this series, I'll show you how to add to your currently empty game world, so go ahead and start creating some graphics to use!
--------------------------------------------------------------------------------
via: https://opensource.com/article/17/12/game-framework-python
作者:[Seth Kenlon][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/seth
[b]: https://github.com/lujun9972
[1]: https://opensource.com/article/17/10/python-101
[2]: http://www.pygame.org/wiki/about
[3]: https://en.wikipedia.org/wiki/IDLE
[4]: http://ninja-ide.org/
[5]: http://krita.org
[6]: https://gumroad.com/l/krita-game-art-tutorial-1
[7]: https://pinta-project.com/pintaproject/pinta/releases
[8]: http://inkscape.org
[9]: https://opensource.com/article/17/12/program-game-python-part-3-spawning-player

View File

@ -0,0 +1,162 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How to add a player to your Python game)
[#]: via: (https://opensource.com/article/17/12/game-python-add-a-player)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
How to add a player to your Python game
======
Part three of a series on building a game from scratch with Python.
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/python3-game.png?itok=jG9UdwC3)
In the [first article of this series][1], I explained how to use Python to create a simple, text-based dice game. In the second part, I showed you how to build a game from scratch, starting with [creating the game's environment][2]. But every game needs a player, and every player needs a playable character, so that's what we'll do next in the third part of the series.
In Pygame, the icon or avatar that a player controls is called a sprite. If you don't have any graphics to use for a player sprite yet, create something for yourself using [Krita][3] or [Inkscape][4]. If you lack confidence in your artistic skills, you can also search [OpenClipArt.org][5] or [OpenGameArt.org][6] for something pre-generated. Then, if you didn't already do so in the previous article, create a directory called `images` alongside your Python project directory. Put the images you want to use in your game into the `images` folder.
To make your game truly exciting, you ought to use an animated sprite for your hero. It means you have to draw more assets, but it makes a big difference. The most common animation is a walk cycle, a series of drawings that make it look like your sprite is walking. The quick and dirty version of a walk cycle requires four drawings.
![](https://opensource.com/sites/default/files/u128651/walk-cycle-poses.jpg)
Note: The code samples in this article allow for both a static player sprite and an animated one.
Name your player sprite `hero.png`. If you're creating an animated sprite, append a digit after the name, starting with `hero1.png`.
### Create a Python class
In Python, when you create an object that you want to appear on screen, you create a class.
Near the top of your Python script, add the code to create a player. In the code sample below, the first three lines are already in the Python script that you're working on:
```
import pygame
import sys
import os # new code below
class Player(pygame.sprite.Sprite):
    '''
    Spawn a player
    '''
    def __init__(self):
        pygame.sprite.Sprite.__init__(self)
        self.images = []
    img = pygame.image.load(os.path.join('images','hero.png')).convert()
    self.images.append(img)
    self.image = self.images[0]
    self.rect  = self.image.get_rect()
```
If you have a walk cycle for your playable character, save each drawing as an individual file called `hero1.png` to `hero4.png` in the `images` folder.
Use a loop to tell Python to cycle through each file.
```
'''
Objects
'''
class Player(pygame.sprite.Sprite):
    '''
    Spawn a player
    '''
    def __init__(self):
        pygame.sprite.Sprite.__init__(self)
        self.images = []
        for i in range(1,5):
            img = pygame.image.load(os.path.join('images','hero' + str(i) + '.png')).convert()
            self.images.append(img)
            self.image = self.images[0]
            self.rect  = self.image.get_rect()
```
### Bring the player into the game world
Now that a Player class exists, you must use it to spawn a player sprite in your game world. If you never call on the Player class, it never runs, and there will be no player. You can test this out by running your game now. The game will run just as well as it did at the end of the previous article, with the exact same results: an empty game world.
To bring a player sprite into your world, you must call the Player class to generate a sprite and then add it to a Pygame sprite group. In this code sample, the first three lines are existing code, so add the lines afterwards:
```
world       = pygame.display.set_mode([worldx,worldy])
backdrop    = pygame.image.load(os.path.join('images','stage.png')).convert()
backdropbox = screen.get_rect()
# new code below
player = Player()   # spawn player
player.rect.x = 0   # go to x
player.rect.y = 0   # go to y
player_list = pygame.sprite.Group()
player_list.add(player)
```
Try launching your game to see what happens. Warning: it won't do what you expect. When you launch your project, the player sprite doesn't spawn. Actually, it spawns, but only for a millisecond. How do you fix something that only happens for a millisecond? You might recall from the previous article that you need to add something to the main loop. To make the player spawn for longer than a millisecond, tell Python to draw it once per loop.
Change the bottom clause of your loop to look like this:
```
    world.blit(backdrop, backdropbox)
    player_list.draw(screen) # draw player
    pygame.display.flip()
    clock.tick(fps)
```
Launch your game now. Your player spawns!
### Setting the alpha channel
Depending on how you created your player sprite, it may have a colored block around it. What you are seeing is the space that ought to be occupied by an alpha channel. It's meant to be the "color" of invisibility, but Python doesn't know to make it invisible yet. What you are seeing, then, is the space within the bounding box (or "hit box," in modern gaming terms) around the sprite.
![](https://opensource.com/sites/default/files/u128651/greenscreen.jpg)
You can tell Python what color to make invisible by setting an alpha channel and using RGB values. If you don't know the RGB values your drawing uses as alpha, open your drawing in Krita or Inkscape and fill the empty space around your drawing with a unique color, like #00ff00 (more or less a "greenscreen green"). Take note of the color's hex value (#00ff00, for greenscreen green) and use that in your Python script as the alpha channel.
Using alpha requires the addition of two lines in your Sprite creation code. Some version of the first line is already in your code. Add the other two lines:
```
            img = pygame.image.load(os.path.join('images','hero' + str(i) + '.png')).convert()
            img.convert_alpha()     # optimise alpha
            img.set_colorkey(ALPHA) # set alpha
```
Python doesn't know what to use as alpha unless you tell it. In the setup area of your code, add some more color definitions. Add this variable definition anywhere in your setup section:
```
ALPHA = (0, 255, 0)
```
In this example code, **0,255,0** is used, which is the same value in RGB as #00ff00 is in hex. You can get all of these color values from a good graphics application like [GIMP][7], Krita, or Inkscape. Alternately, you can also detect color values with a good system-wide color chooser, like [KColorChooser][8].
![](https://opensource.com/sites/default/files/u128651/kcolor.png)
If your graphics application is rendering your sprite's background as some other value, adjust the values of your alpha variable as needed. No matter what you set your alpha value, it will be made "invisible." RGB values are very strict, so if you need to use 000 for alpha, but you need 000 for the black lines of your drawing, just change the lines of your drawing to 111, which is close enough to black that nobody but a computer can tell the difference.
Launch your game to see the results.
![](https://opensource.com/sites/default/files/u128651/alpha.jpg)
In the [fourth part of this series][9], I'll show you how to make your sprite move. How exciting!
--------------------------------------------------------------------------------
via: https://opensource.com/article/17/12/game-python-add-a-player
作者:[Seth Kenlon][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/seth
[b]: https://github.com/lujun9972
[1]: https://opensource.com/article/17/10/python-101
[2]: https://opensource.com/article/17/12/program-game-python-part-2-creating-game-world
[3]: http://krita.org
[4]: http://inkscape.org
[5]: http://openclipart.org
[6]: https://opengameart.org/
[7]: http://gimp.org
[8]: https://github.com/KDE/kcolorchooser
[9]: https://opensource.com/article/17/12/program-game-python-part-4-moving-your-sprite

View File

@ -1,5 +1,5 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: translator: (GraveAccent)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )

View File

@ -0,0 +1,353 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Using Pygame to move your game character around)
[#]: via: (https://opensource.com/article/17/12/game-python-moving-player)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
Using Pygame to move your game character around
======
In the fourth part of this series, learn how to code the controls needed to move a game character.
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/python4-game.png?itok=tXFHaLdt)
In the first article in this series, I explained how to use Python to create a simple, [text-based dice game][1]. In the second part, we began building a game from scratch, starting with [creating the game's environment][2]. And, in the third installment, we [created a player sprite][3] and made it spawn in your (rather empty) game world. As you've probably noticed, a game isn't much fun if you can't move your character around. In this article, we'll use Pygame to add keyboard controls so you can direct your character's movement.
There are functions in Pygame to add other kinds of controls, but since you certainly have a keyboard if you're typing out Python code, that's what we'll use. Once you understand keyboard controls, you can explore other options on your own.
You created a key to quit your game in the second article in this series, and the principle is the same for movement. However, getting your character to move is a little more complex.
Let's start with the easy part: setting up the controller keys.
### Setting up keys for controlling your player sprite
Open your Python game script in IDLE, Ninja-IDE, or a text editor.
Since the game must constantly "listen" for keyboard events, you'll be writing code that needs to run continuously. Can you figure out where to put code that needs to run constantly for the duration of the game?
If you answered "in the main loop," you're correct! Remember that unless code is in a loop, it will run (at most) only once—and it may not run at all if it's hidden away in a class or function that never gets used.
To make Python monitor for incoming key presses, add this code to the main loop. There's no code to make anything happen yet, so use `print` statements to signal success. This is a common debugging technique.
```
while main == True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit(); sys.exit()
            main = False
        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_LEFT or event.key == ord('a'):
                print('left')
            if event.key == pygame.K_RIGHT or event.key == ord('d'):
                print('right')
            if event.key == pygame.K_UP or event.key == ord('w'):
            print('jump')
        if event.type == pygame.KEYUP:
            if event.key == pygame.K_LEFT or event.key == ord('a'):
                print('left stop')
            if event.key == pygame.K_RIGHT or event.key == ord('d'):
                print('right stop')
            if event.key == ord('q'):
                pygame.quit()
                sys.exit()
                main = False    
```
Some people prefer to control player characters with the keyboard characters W, A, S, and D, and others prefer to use arrow keys. Be sure to include both options.
**Note: **It's vital that you consider all of your users when programming. If you write code that works only for you, it's very likely that you'll be the only one who uses your application. More importantly, if you seek out a job writing code for money, you are expected to write code that works for everyone. Giving your users choices, such as the option to use either arrow keys or WASD, is a sign of a good programmer.
Launch your game using Python, and watch the console window for output as you press the right, left, and up arrows, or the A, D, and W keys.
```
$ python ./your-name_game.py
  left
  left stop
  right
  right stop
  jump
```
This confirms that Pygame detects key presses correctly. Now it's time to do the hard work of making the sprite move.
### Coding the player movement function
To make your sprite move, you must create a property for your sprite that represents movement. When your sprite is not moving, this variable is set to `0`.
If you are animating your sprite, or should you decide to animate it in the future, you also must track frames to enable the walk cycle to stay on track.
Create the variables in the Player class. The first two lines are for context (you already have them in your code, if you've been following along), so add only the last three:
```
    def __init__(self):
        pygame.sprite.Sprite.__init__(self)
        self.movex = 0 # move along X
        self.movey = 0 # move along Y
        self.frame = 0 # count frames
```
With those variables set, it's time to code the sprite's movement.
The player sprite doesn't need to respond to control all the time; sometimes it will not be moving. The code that controls the sprite, therefore, is only one small part of all the things the player sprite will do. When you want to make an object in Python do something independent of the rest of its code, you place your new code in a function. Python functions start with the keyword `def`, which stands for define.
Make a function in your Player class to add some number of pixels to your sprite's position on screen. Don't worry about how many pixels you add yet; that will be decided in later code.
```
    def control(self,x,y):
        '''
        control player movement
        '''
        self.movex += x
        self.movey += y
```
To move a sprite in Pygame, you have to tell Python to redraw the sprite in its new location—and where that new location is.
Since the Player sprite isn't always moving, the updates need to be only one function within the Player class. Add this function after the `control` function you created earlier.
To make it appear that the sprite is walking (or flying, or whatever it is your sprite is supposed to do), you need to change its position on screen when the appropriate key is pressed. To get it to move across the screen, you redefine its position, designated by the `self.rect.x` and `self.rect.y` properties, to its current position plus whatever amount of `movex` or `movey` is applied. (The number of pixels the move requires is set later.)
```
    def update(self):
        '''
        Update sprite position
        '''
        self.rect.x = self.rect.x + self.movex        
```
Do the same thing for the Y position:
```
        self.rect.y = self.rect.y + self.movey
```
For animation, advance the animation frames whenever your sprite is moving, and use the corresponding animation frame as the player image:
```
        # moving left
        if self.movex < 0:
            self.frame += 1
            if self.frame > 3*ani:
                self.frame = 0
            self.image = self.images[self.frame//ani]
        # moving right
        if self.movex > 0:
            self.frame += 1
            if self.frame > 3*ani:
                self.frame = 0
            self.image = self.images[(self.frame//ani)+4]
```
Tell the code how many pixels to add to your sprite's position by setting a variable, then use that variable when triggering the functions of your Player sprite.
First, create the variable in your setup section. In this code, the first two lines are for context, so just add the third line to your script:
```
player_list = pygame.sprite.Group()
player_list.add(player)
steps = 10  # how many pixels to move
```
Now that you have the appropriate function and variable, use your key presses to trigger the function and send the variable to your sprite.
Do this by replacing the `print` statements in your main loop with the Player sprite's name (player), the function (.control), and how many steps along the X axis and Y axis you want the player sprite to move with each loop.
```
        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_LEFT or event.key == ord('a'):
                player.control(-steps,0)
            if event.key == pygame.K_RIGHT or event.key == ord('d'):
                player.control(steps,0)
            if event.key == pygame.K_UP or event.key == ord('w'):
                print('jump')
        if event.type == pygame.KEYUP:
            if event.key == pygame.K_LEFT or event.key == ord('a'):
                player.control(steps,0)
            if event.key == pygame.K_RIGHT or event.key == ord('d'):
                player.control(-steps,0)
            if event.key == ord('q'):
                pygame.quit()
                sys.exit()
                main = False
```
Remember, `steps` is a variable representing how many pixels your sprite moves when a key is pressed. If you add 10 pixels to the location of your player sprite when you press D or the right arrow, then when you stop pressing that key you must subtract 10 (`-steps`) to return your sprite's momentum back to 0.
Try your game now. Warning: it won't do what you expect.
Why doesn't your sprite move yet? Because the main loop doesn't call the `update` function.
Add code to your main loop to tell Python to update the position of your player sprite. Add the line with the comment:
```
    player.update()  # update player position
    player_list.draw(world)
    pygame.display.flip()
    clock.tick(fps)
```
Launch your game again to witness your player sprite move across the screen at your bidding. There's no vertical movement yet because those functions will be controlled by gravity, but that's another lesson for another article.
In the meantime, if you have access to a joystick, try reading Pygame's documentation for its [joystick][4] module and see if you can make your sprite move that way. Alternately, see if you can get the [mouse][5] to interact with your sprite.
Most importantly, have fun!
### All the code used in this tutorial
For your reference, here is all the code used in this series of articles so far.
```
#!/usr/bin/env python3
# draw a world
# add a player and player control
# add player movement
# GNU All-Permissive License
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved. This file is offered as-is,
# without any warranty.
import pygame
import sys
import os
'''
Objects
'''
class Player(pygame.sprite.Sprite):
'''
Spawn a player
'''
def __init__(self):
pygame.sprite.Sprite.__init__(self)
self.movex = 0
self.movey = 0
self.frame = 0
self.images = []
for i in range(1,5):
img = pygame.image.load(os.path.join('images','hero' + str(i) + '.png')).convert()
img.convert_alpha()
img.set_colorkey(ALPHA)
self.images.append(img)
self.image = self.images[0]
self.rect = self.image.get_rect()
def control(self,x,y):
'''
control player movement
'''
self.movex += x
self.movey += y
def update(self):
'''
Update sprite position
'''
self.rect.x = self.rect.x + self.movex
self.rect.y = self.rect.y + self.movey
# moving left
if self.movex < 0:
self.frame += 1
if self.frame > 3*ani:
self.frame = 0
self.image = self.images[self.frame//ani]
# moving right
if self.movex > 0:
self.frame += 1
if self.frame > 3*ani:
self.frame = 0
self.image = self.images[(self.frame//ani)+4]
'''
Setup
'''
worldx = 960
worldy = 720
fps = 40 # frame rate
ani = 4 # animation cycles
clock = pygame.time.Clock()
pygame.init()
main = True
BLUE = (25,25,200)
BLACK = (23,23,23 )
WHITE = (254,254,254)
ALPHA = (0,255,0)
world = pygame.display.set_mode([worldx,worldy])
backdrop = pygame.image.load(os.path.join('images','stage.png')).convert()
backdropbox = world.get_rect()
player = Player() # spawn player
player.rect.x = 0
player.rect.y = 0
player_list = pygame.sprite.Group()
player_list.add(player)
steps = 10 # how fast to move
'''
Main loop
'''
while main == True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit(); sys.exit()
main = False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT or event.key == ord('a'):
player.control(-steps,0)
if event.key == pygame.K_RIGHT or event.key == ord('d'):
player.control(steps,0)
if event.key == pygame.K_UP or event.key == ord('w'):
print('jump')
if event.type == pygame.KEYUP:
if event.key == pygame.K_LEFT or event.key == ord('a'):
player.control(steps,0)
if event.key == pygame.K_RIGHT or event.key == ord('d'):
player.control(-steps,0)
if event.key == ord('q'):
pygame.quit()
sys.exit()
main = False
# world.fill(BLACK)
world.blit(backdrop, backdropbox)
player.update()
player_list.draw(world) #refresh player position
pygame.display.flip()
clock.tick(fps)
```
You've come far and learned much, but there's a lot more to do. In the next few articles, you'll add enemy sprites, emulated gravity, and lots more. In the mean time, practice with Python!
--------------------------------------------------------------------------------
via: https://opensource.com/article/17/12/game-python-moving-player
作者:[Seth Kenlon][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/seth
[b]: https://github.com/lujun9972
[1]: https://opensource.com/article/17/10/python-101
[2]: https://opensource.com/article/17/12/program-game-python-part-2-creating-game-world
[3]: https://opensource.com/article/17/12/program-game-python-part-3-spawning-player
[4]: http://pygame.org/docs/ref/joystick.html
[5]: http://pygame.org/docs/ref/mouse.html#module-pygame.mouse

View File

@ -0,0 +1,58 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Get started with Cypht, an open source email client)
[#]: via: (https://opensource.com/article/19/1/productivity-tool-cypht-email)
[#]: author: (Kevin Sonney https://opensource.com/users/ksonney (Kevin Sonney))
Get started with Cypht, an open source email client
======
Integrate your email and news feeds into one view with Cypht, the fourth in our series on 19 open source tools that will make you more productive in 2019.
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/email_mail_box_envelope_send_blue.jpg?itok=6Epj47H6)
There seems to be a mad rush at the beginning of every year to find ways to be more productive. New Year's resolutions, the itch to start the year off right, and of course, an "out with the old, in with the new" attitude all contribute to this. And the usual round of recommendations is heavily biased towards closed source and proprietary software. It doesn't have to be that way.
Here's the fourth of my picks for 19 new (or new-to-you) open source tools to help you be more productive in 2019.
### Cypht
We spend a lot of time dealing with email, and effectively [managing your email][1] can make a huge impact on your productivity. Programs like Thunderbird, Kontact/KMail, and Evolution all seem to have one thing in common: they seek to duplicate the functionality of Microsoft Outlook, which hasn't really changed in the last 10 years or so. Even the [console standard-bearers][2] like Mutt and Cone haven't changed much in the last decade.
![](https://opensource.com/sites/default/files/uploads/cypht-1.png)
[Cypht][3] is a simple, lightweight, and modern webmail client that aggregates several accounts into a single view. Along with email accounts, it includes Atom/RSS feeds. It makes reading items from these different sources very simple by using an "Everything" screen that shows not just the mail from your inbox, but also the newest articles from your news feeds.
![](https://opensource.com/sites/default/files/uploads/cypht-2.png)
It uses a simplified version of HTML messages to display mail or you can set it to view a plain-text version. Since Cypht doesn't load images from remote sources (to help maintain security), HTML rendering can be a little rough, but it does enough to get the job done. You'll get plain-text views with most rich-text mail—meaning lots of links and hard to read. I don't fault Cypht, since this is really the email senders' doing, but it does detract a little from the reading experience. Reading news feeds is about the same, but having them integrated with your email accounts makes it much easier to keep up with them (something I sometimes have issues with).
![](https://opensource.com/sites/default/files/uploads/cypht-3.png)
Users can use a preconfigured mail server and add any additional servers they use. Cypht's customization options include plain-text vs. HTML mail display, support for multiple profiles, and the ability to change the theme (and make your own). You have to remember to click the "Save" button on the left navigation bar, though, or your custom settings will disappear after that session. If you log out and back in without saving, all your changes will be lost and you'll end up with the settings you started with. This does make it easy to experiment, and if you need to reset things, simply logging out without saving will bring back the previous setup when you log back in.
![](https://opensource.com/sites/default/files/pictures/cypht-4.png)
[Installing Cypht][4] locally is very easy. While it is not in a container or similar technology, the setup instructions were very clear and easy to follow and didn't require any changes on my part. On my laptop, it took about 10 minutes from starting the installation to logging in for the first time. A shared installation on a server uses the same steps, so it should be about the same.
In the end, Cypht is a fantastic alternative to desktop and web-based email clients with a simple interface to help you handle your email quickly and efficiently.
--------------------------------------------------------------------------------
via: https://opensource.com/article/19/1/productivity-tool-cypht-email
作者:[Kevin Sonney][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/ksonney (Kevin Sonney)
[b]: https://github.com/lujun9972
[1]: https://opensource.com/article/17/7/email-alternatives-thunderbird
[2]: https://opensource.com/life/15/8/top-4-open-source-command-line-email-clients
[3]: https://cypht.org/
[4]: https://cypht.org/install.html

View File

@ -0,0 +1,58 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Get started with CryptPad, an open source collaborative document editor)
[#]: via: (https://opensource.com/article/19/1/productivity-tool-cryptpad)
[#]: author: (Kevin Sonney https://opensource.com/users/ksonney (Kevin Sonney))
Get started with CryptPad, an open source collaborative document editor
======
Securely share your notes, documents, kanban boards, and more with CryptPad, the fifth in our series on open source tools that will make you more productive in 2019.
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/web_browser_desktop_devlopment_design_system_computer.jpg?itok=pfqRrJgh)
There seems to be a mad rush at the beginning of every year to find ways to be more productive. New Year's resolutions, the itch to start the year off right, and of course, an "out with the old, in with the new" attitude all contribute to this. And the usual round of recommendations is heavily biased towards closed source and proprietary software. It doesn't have to be that way.
Here's the fifth of my picks for 19 new (or new-to-you) open source tools to help you be more productive in 2019.
### CryptPad
We already talked about [Joplin][1], which is good for keeping your own notes but—as you may have noticed—doesn't have any sharing or collaboration features.
[CryptPad][2] is a secure, shareable note-taking app and document editor that allows for secure, collaborative editing. Unlike Joplin, it is a NodeJS app, which means you can run it on your desktop or a server elsewhere and access it with any modern web browser. Out of the box, it supports rich text, Markdown, polls, whiteboards, kanban, and presentations.
![](https://opensource.com/sites/default/files/uploads/cryptpad-1.png)
The different document types are robust and fully featured. The rich text editor covers all the bases you'd expect from a good editor and allows you to export files to HTML. The Markdown editor is on par with Joplin, and the kanban board, though not as full-featured as [Wekan][3], is really well done. The rest of the supported document types and editors are also very polished and have the features you'd expect from similar apps, although polls feel a little clunky.
![](https://opensource.com/sites/default/files/uploads/cryptpad-2.png)
CryptPad's real power, though, comes in its sharing and collaboration features. Sharing a document is as simple as getting the sharable URL from the "share" option, and CryptPad supports embedding documents in iFrame tags on other websites. Documents can be shared in Edit or View mode with a password and with links that expire. The built-in chat allows editors to talk to each other (note that people with View access can also see the chat but can't comment).
![](https://opensource.com/sites/default/files/pictures/cryptpad-3.png)
All files are stored encrypted with the user's password. Server administrators can't read the documents, which also means if you forget or lose your password, the files are unrecoverable. So make sure you keep the password in a secure place, like a [password vault][4].
![](https://opensource.com/sites/default/files/uploads/cryptpad-4.png)
When it's run locally, CryptPad is a robust app for creating and editing documents. When run on a server, it becomes an excellent collaboration platform for multi-user document creation and editing. Installation took less than five minutes on my laptop, and it just worked out of the box. The developers also include instructions for running CryptPad in Docker, and there is a community-maintained Ansible role for ease of deployment. CryptPad does not support any third-party authentication methods, so users must create their own accounts. CryptPad also has a community-supported hosted version if you don't want to run your own server.
--------------------------------------------------------------------------------
via: https://opensource.com/article/19/1/productivity-tool-cryptpad
作者:[Kevin Sonney][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/ksonney (Kevin Sonney)
[b]: https://github.com/lujun9972
[1]: https://opensource.com/article/19/1/productivity-tool-joplin
[2]: https://cryptpad.fr/index.html
[3]: https://opensource.com/article/19/1/productivity-tool-wekan
[4]: https://opensource.com/article/18/4/3-password-managers-linux-command-line

View File

@ -1,5 +1,5 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )

View File

@ -0,0 +1,61 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Get started with Freeplane, an open source mind mapping application)
[#]: via: (https://opensource.com/article/19/1/productivity-tool-freeplane)
[#]: author: (Kevin Sonney https://opensource.com/users/ksonney (Kevin Sonney))
Get started with Freeplane, an open source mind mapping application
======
Map your brainstorming sessions with Freeplane, the 13th in our series on open source tools that will make you more productive in 2019.
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/brain_data.png?itok=RH6NA32X)
There seems to be a mad rush at the beginning of every year to find ways to be more productive. New Year's resolutions, the itch to start the year off right, and of course, an "out with the old, in with the new" attitude all contribute to this. And the usual round of recommendations is heavily biased towards closed source and proprietary software. It doesn't have to be that way.
Here's the 13th of my picks for 19 new (or new-to-you) open source tools to help you be more productive in 2019.
### Freeplane
[Mind maps][1] are one of the more valuable tools I've used for quickly brainstorming ideas and capturing data. Mind mapping is a versatile process that helps show how things are related and can be used to quickly organize interrelated information. From a planning perspective, mind mapping allows you to quickly perform a brain dump around a single concept, idea, or technology.
![](https://opensource.com/sites/default/files/uploads/freeplane-1.png)
[Freeplane][2] is a desktop application that makes it easy to create, view, edit, and share mind maps. It is a redesign of [FreeMind][3], which was the go-to mind-mapping application for quite some time.
Installing Freeplane is pretty easy. It is a [Java][4] application and distributed as a ZIP file with scripts to start the application on Linux, Windows, and MacOS. At its first startup, its main window includes an example mind map with links to documentation about all the different things you can do with Freeplane.
![](https://opensource.com/sites/default/files/uploads/freeplane-2.png)
You have a choice of templates when you create a new mind map. The standard template (likely at the bottom of the list) works for most cases. Just start typing the idea or phrase you want to start with, and your text will replace the center text. Pressing the Insert key will add a branch (or node) off the center with a blank field where you can fill in something associated with the idea. Pressing Insert again will add another node connected to the first one. Pressing Enter on a node will add a node parallel to that one.
![](https://opensource.com/sites/default/files/uploads/freeplane-3.png)
As you add nodes, you may come up with another thought or idea related to the main topic. Using either the mouse or the Arrow keys, go back to the center of the map and press Insert. A new node will be created off the main topic.
If you want to go beyond Freeplane's base functionality, right-click on any of the nodes to bring up a Properties menu for that node. The Tool pane (activated under the View>Controls menu) contains customization options galore, including line shape and thickness, border shapes, colors, and much, much more. The Calendar tab allows you to insert dates into the nodes and set reminders for when nodes are due. (Note that reminders work only when Freeplane is running.) Mind maps can be exported to several formats, including common images, XML, Microsoft Project, Markdown, and OPML.
![](https://opensource.com/sites/default/files/uploads/freeplane-4.png)
Freeplane gives you all the tools you'll need to create vibrant and useful mind maps, getting your ideas out of your head and into a place where you can take action on them.
--------------------------------------------------------------------------------
via: https://opensource.com/article/19/1/productivity-tool-freeplane
作者:[Kevin Sonney][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/ksonney (Kevin Sonney)
[b]: https://github.com/lujun9972
[1]: https://en.wikipedia.org/wiki/Mind_map
[2]: https://www.freeplane.org/wiki/index.php/Home
[3]: https://sourceforge.net/projects/freemind/
[4]: https://java.com

View File

@ -1,5 +1,5 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: translator: (zero-MK)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )

View File

@ -1,114 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How To SSH Into A Particular Directory On Linux)
[#]: via: (https://www.ostechnix.com/how-to-ssh-into-a-particular-directory-on-linux/)
[#]: author: (SK https://www.ostechnix.com/author/sk/)
How To SSH Into A Particular Directory On Linux
======
![](https://www.ostechnix.com/wp-content/uploads/2019/02/SSH-Into-A-Particular-Directory-720x340.png)
Have you ever been in a situation where you want to SSH to a remote server and immediately cd into a directory and continue work interactively? Youre on the right track! This brief tutorial describes how to directly SSH into a particular directory of a remote Linux system. Not just SSH into a specific directory, you can run any command immediately right after connecting to an SSH server as described in this guide. It is not that difficult as you might think. Read on.
### SSH Into A Particular Directory Of A Remote System
Before I knew this method, I would usually first SSH to the remote remote system using command:
```
$ ssh user@remote-system
```
And then cd into a directory like below:
```
$ cd <some-directory>
```
However, you need not to use two separate commands. You can combine these commands and simplify the task with one command.
Have a look at the following example.
```
$ ssh -t sk@192.168.225.22 'cd /home/sk/ostechnix ; bash'
```
The above command will SSH into a remote system (192.168.225.22) and immediately cd into a directory named **/home/sk/ostechnix/** directory and leave yourself at the prompt.
Here, the **-t** flag is used to force pseudo-terminal allocation, which is necessary or an interactive shell.
Here is the sample output of the above command:
![](https://www.ostechnix.com/wp-content/uploads/2019/02/ssh-1.gif)
You can also use this command as well.
```
$ ssh -t sk@192.168.225.22 'cd /home/sk/ostechnix ; exec bash'
```
Or,
```
$ ssh -t sk@192.168.225.22 'cd /home/sk/ostechnix && exec bash -l'
```
Here, the **-l** flag sets the bash as login shell.
In the above example, I have used **bash** in the last argument. It is the default shell in my remote system. If you dont know the shell type on the remote system, use the following command:
```
$ ssh -t sk@192.168.225.22 'cd /home/sk/ostechnix && exec $SHELL'
```
Like I already said, this is not just for cd into directory after connecting to an remote system. You can use this trick to run other commands as well. For example, the following command will land you inside /home/sk/ostechnix/ directory and then execute uname -a command.
```
$ ssh -t sk@192.168.225.22 'cd /home/sk/ostechnix && uname -a && exec $SHELL'
```
Alternatively, you can add the command(s) you wanted to run after connecting to an SSH server on the remote systems **.bash_profile** file.
Edit **.bash_profile** file:
```
$ nano ~/.bash_profile
```
Add the command(s) one by one. In my case, I am adding the following line:
```
cd /home/sk/ostechnix >& /dev/null
```
Save and close the file. Finally, run the following command to update the changes.
```
$ source ~/.bash_profile
```
Please note that you should add this line on the remote systems **.bash_profile** or **.bashrc** file, not in your local systems. From now on, whenever you login (whether by SSH or direct), the cd command will execute and you will be automatically landed inside “/home/sk/ostechnix/” directory.
And, thats all for now. Hope this was useful. More good stuffs to come. Stay tuned!
Cheers!
--------------------------------------------------------------------------------
via: https://www.ostechnix.com/how-to-ssh-into-a-particular-directory-on-linux/
作者:[SK][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.ostechnix.com/author/sk/
[b]: https://github.com/lujun9972

View File

@ -0,0 +1,309 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (ClusterShell A Nifty Tool To Run Commands On Cluster Nodes In Parallel)
[#]: via: (https://www.2daygeek.com/clustershell-clush-run-commands-on-cluster-nodes-remote-system-in-parallel-linux/)
[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/)
ClusterShell A Nifty Tool To Run Commands On Cluster Nodes In Parallel
======
We had written two articles in the past to run commands on multiple remote server in parallel.
These are **[Parallel SSH (PSSH)][1]** or **[Distributed Shell (DSH)][2]**.
Today also, we are going to discuss about the same kind of topic but it allows us to perform the same on cluster nodes as well.
You may think, i can write a small shell script to archive this instead of installing these third party packages.
Of course you are right and if you are going to run some commands in 10-15 remote systems then you dont need to use this.
However, the scripts take some time to complete this task as its running in a sequential order.
Think about if you would like to run some commands on 1000+ servers what will be the options?
In this case your script wont help you. Also, it would take good amount of time to complete a task.
So, to overcome this kind of issue and situation. We need to run the command in parallel on remote machines.
For that, we need use in one of the Parallel applications. I hope this explanation might fulfilled your doubts about parallel utilities.
### What Is ClusterShell?
clush stands for [ClusterShell][3]. ClusterShell is an event-driven open source Python library, designed to run local or distant commands in parallel on server farms or on large Linux clusters.
It will take care of common issues encountered on HPC clusters, such as operating on groups of nodes, running distributed commands using optimized execution algorithms, as well as gathering results and merging identical outputs, or retrieving return codes.
ClusterShell takes advantage of existing remote shell facilities already installed on your systems, like SSH.
ClusterShells primary goal is to improve the administration of high- performance clusters by providing a lightweight but scalable Python API for developers. It also provides clush, clubak and cluset/nodeset, convenient command-line tools that allow traditional shell scripts to benefit from some of the library features.
ClusterShells written in Python and it requires Python (v2.6+ or v3.4+) to run on your system.
### How To Install ClusterShell On Linux?
ClusterShell package is available in most of the distribution official package manager. So, use the distribution package manager tool to install it.
For **`Fedora`** system, use **[DNF Command][4]** to install clustershell.
```
$ sudo dnf install clustershell
```
Python 2 module and tools are installed and if its default on your system then run the following command to install Python 3 development on Fedora System.
```
$ sudo dnf install python3-clustershell
```
Make sure you should have enabled the **[EPEL repository][5]** on your system before performing clustershell installation.
For **`RHEL/CentOS`** systems, use **[YUM Command][6]** to install clustershell.
```
$ sudo yum install clustershell
```
Python 2 module and tools are installed and if its default on your system then run the following command to install Python 3 development on CentOS/RHEL System.
```
$ sudo yum install python34-clustershell
```
For **`openSUSE Leap`** system, use **[Zypper Command][7]** to install clustershell.
```
$ sudo zypper install clustershell
```
Python 2 module and tools are installed and if its default on your system then run the following command to install Python 3 development on OpenSUSE System.
```
$ sudo zypper install python3-clustershell
```
For **`Debian/Ubuntu`** systems, use **[APT-GET Command][8]** or **[APT Command][9]** to install clustershell.
```
$ sudo apt install clustershell
```
### How To Install ClusterShell In Linux Using PIP?
Use PIP to install ClusterShell because its written in Python.
Make sure you should have enabled the **[Python][10]** and **[PIP][11]** on your system before performing clustershell installation.
```
$ sudo pip install ClusterShell
```
### How To Use ClusterShell On Linux?
Its straight forward and awesome tool compared with other utilities such as pssh and dsh. It has so many options to perform the remote execution in parallel.
Make sure you should have enabled the **[password less login][12]** on your system before start using clustershell.
The following configuration file defines system-wide default values. You no need to modify anything here.
```
$ cat /etc/clustershell/clush.conf
```
If you would like to create a servers group. Here you can go. By default some examples were available so, do the same for your requirements.
```
$ cat /etc/clustershell/groups.d/local.cfg
```
Just run the clustershell command in the following format to get the information from the given nodes.
```
$ clush -w 192.168.1.4,192.168.1.9 cat /proc/version
192.168.1.9: Linux version 4.15.0-45-generic ([email protected]) (gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3)) #48-Ubuntu SMP Tue Jan 29 16:28:13 UTC 2019
192.168.1.4: Linux version 3.10.0-957.el7.x86_64 ([email protected]) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) ) #1 SMP Thu Nov 8 23:39:32 UTC 2018
```
**Option:**
* **`-w:`** nodes where to run the command.
You can use the regular expressions instead of using full hostname and IPs.
```
$ clush -w 192.168.1.[4,9] uname -r
192.168.1.9: 4.15.0-45-generic
192.168.1.4: 3.10.0-957.el7.x86_64
```
Alternatively you can use the following format if you have the servers in the same IP series.
```
$ clush -w 192.168.1.[4-9] date
192.168.1.6: Mon Mar 4 21:08:29 IST 2019
192.168.1.7: Mon Mar 4 21:08:29 IST 2019
192.168.1.8: Mon Mar 4 21:08:29 IST 2019
192.168.1.5: Mon Mar 4 09:16:30 CST 2019
192.168.1.9: Mon Mar 4 21:08:29 IST 2019
192.168.1.4: Mon Mar 4 09:16:30 CST 2019
```
clustershell allow us to run the command in batch mode. Use the following format to achieve this.
```
$ clush -w 192.168.1.4,192.168.1.9 -b
Enter 'quit' to leave this interactive mode
Working with nodes: 192.168.1.[4,9]
clush> hostnamectl
---------------
192.168.1.4
---------------
Static hostname: CentOS7.2daygeek.com
Icon name: computer-vm
Chassis: vm
Machine ID: 002f47b82af248f5be1d67b67e03514c
Boot ID: f9b37a073c534dec8b236885e754cb56
Virtualization: kvm
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-957.el7.x86_64
Architecture: x86-64
---------------
192.168.1.9
---------------
Static hostname: Ubuntu18
Icon name: computer-vm
Chassis: vm
Machine ID: 27f6c2febda84dc881f28fd145077187
Boot ID: f176f2eb45524d4f906d12e2b5716649
Virtualization: oracle
Operating System: Ubuntu 18.04.2 LTS
Kernel: Linux 4.15.0-45-generic
Architecture: x86-64
clush> free -m
---------------
192.168.1.4
---------------
total used free shared buff/cache available
Mem: 1838 641 217 19 978 969
Swap: 2047 0 2047
---------------
192.168.1.9
---------------
total used free shared buff/cache available
Mem: 1993 352 1067 1 573 1473
Swap: 1425 0 1425
clush> w
---------------
192.168.1.4
---------------
09:21:14 up 3:21, 3 users, load average: 0.00, 0.01, 0.05
USER TTY FROM [email protected] IDLE JCPU PCPU WHAT
daygeek :0 :0 06:02 ?xdm? 1:28 0.30s /usr/libexec/gnome-session-binary --session gnome-classic
daygeek pts/0 :0 06:03 3:17m 0.06s 0.06s bash
daygeek pts/1 192.168.1.6 06:03 52:26 0.10s 0.10s -bash
---------------
192.168.1.9
---------------
21:13:12 up 3:12, 1 user, load average: 0.08, 0.03, 0.00
USER TTY FROM [email protected] IDLE JCPU PCPU WHAT
daygeek pts/0 192.168.1.6 20:42 29:41 0.05s 0.05s -bash
clush> quit
```
If you would like to run the command on a group of nodes then use the following format.
```
$ clush -w @dev uptime
or
$ clush -g dev uptime
or
$ clush --group=dev uptime
192.168.1.9: 21:10:10 up 3:09, 1 user, load average: 0.09, 0.03, 0.01
192.168.1.4: 09:18:12 up 3:18, 3 users, load average: 0.01, 0.02, 0.05
```
If you would like to run the command on more than one group of nodes then use the following format.
```
$ clush -w @dev,@uat uptime
or
$ clush -g dev,uat uptime
or
$ clush --group=dev,uat uptime
192.168.1.7: 07:57:19 up 59 min, 1 user, load average: 0.08, 0.03, 0.00
192.168.1.9: 20:27:20 up 1:00, 1 user, load average: 0.00, 0.00, 0.00
192.168.1.5: 08:57:21 up 59 min, 1 user, load average: 0.00, 0.01, 0.05
```
clustershell allow us to copy a file to remote machines. To copy local file or directory to the remote nodes in the same location.
```
$ clush -w 192.168.1.[4,9] --copy /home/daygeek/passwd-up.sh
```
We can verify the same by running the following command.
```
$ clush -w 192.168.1.[4,9] ls -lh /home/daygeek/passwd-up.sh
192.168.1.4: -rwxr-xr-x. 1 daygeek daygeek 159 Mar 4 09:00 /home/daygeek/passwd-up.sh
192.168.1.9: -rwxr-xr-x 1 daygeek daygeek 159 Mar 4 20:52 /home/daygeek/passwd-up.sh
```
To copy local file or directory to the remote nodes in the different location.
```
$ clush -g uat --copy /home/daygeek/passwd-up.sh --dest /tmp
```
We can verify the same by running the following command.
```
$ clush --group=uat ls -lh /tmp/passwd-up.sh
192.168.1.7: -rwxr-xr-x. 1 daygeek daygeek 159 Mar 6 07:44 /tmp/passwd-up.sh
```
To copy file or directory from remote nodes to local system.
```
$ clush -w 192.168.1.7 --rcopy /home/daygeek/Documents/magi.txt --dest /tmp
```
We can verify the same by running the following command.
```
$ ls -lh /tmp/magi.txt.192.168.1.7
-rw-r--r-- 1 daygeek daygeek 35 Mar 6 20:24 /tmp/magi.txt.192.168.1.7
```
--------------------------------------------------------------------------------
via: https://www.2daygeek.com/clustershell-clush-run-commands-on-cluster-nodes-remote-system-in-parallel-linux/
作者:[Magesh Maruthamuthu][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.2daygeek.com/author/magesh/
[b]: https://github.com/lujun9972
[1]: https://www.2daygeek.com/pssh-parallel-ssh-run-execute-commands-on-multiple-linux-servers/
[2]: https://www.2daygeek.com/dsh-run-execute-shell-commands-on-multiple-linux-servers-at-once/
[3]: https://cea-hpc.github.io/clustershell/
[4]: https://www.2daygeek.com/dnf-command-examples-manage-packages-fedora-system/
[5]: https://www.2daygeek.com/install-enable-epel-repository-on-rhel-centos-scientific-linux-oracle-linux/
[6]: https://www.2daygeek.com/yum-command-examples-manage-packages-rhel-centos-systems/
[7]: https://www.2daygeek.com/zypper-command-examples-manage-packages-opensuse-system/
[8]: https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/
[9]: https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/
[10]: https://www.2daygeek.com/3-methods-to-install-latest-python3-package-on-centos-6-system/
[11]: https://www.2daygeek.com/install-pip-manage-python-packages-linux/
[12]: https://www.2daygeek.com/linux-passwordless-ssh-login-using-ssh-keygen/

View File

@ -0,0 +1,141 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Getting started with the Geany text editor)
[#]: via: (https://opensource.com/article/19/3/getting-started-geany-text-editor)
[#]: author: (James Mawson https://opensource.com/users/dxmjames)
Getting started with the Geany text editor
======
Geany is a light and swift text editor with IDE features.
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/web_browser_desktop_devlopment_design_system_computer.jpg?itok=pfqRrJgh)
I have to admit, it took me a rather embarrassingly long time to really get into Linux as a daily driver. One thing I recall from these years in the wilderness was how strange it was to watch open source types get so worked up about text editors.
It wasn't just that opinions differed. Disagreements were intense. And you'd see them again and again.
I mean, I suppose it makes some sense. Doing dev or admin work means you're spending a lot of time with a text editor. And when it gets in the way or won't do quite what you want? In that exact moment, that's the most frustrating thing in the world.
And I know what it means to really hate a text editor. I learned this many years ago in the computer labs at university trying to figure out Emacs. I was quite shocked that a piece of software could have so many sadomasochistic overtones. People were doing that to each other deliberately!
So perhaps it's a rite of passage that now I have one I very much like. It's called [Geany][1], it's on GPL, and it's [in the repositories][2] of most popular distributions.
Here's why it works for me.
### I'm into simplicity
The main thing I want from a text editor is just to edit text. I don't think there should be any kind of learning curve in the way. I should be able to open it and use it.
For that reason, I've generally used whatever is included with an operating system. On Windows 10, I used Notepad far longer than I should have. When I finally replaced it, it was with Notepad++. In the Linux terminal, I like Nano.
I was perfectly aware I was missing out on a lot of useful functionality. But it was never enough of a pain point to make a change. And it's not that I've never tried anything more elaborate. I did some of my first real programming on Visual Basic and Borland Delphi.
These development environments gave you a graphical interface to design your windows visually, various windows where you could configure properties and settings, a text interface to write your functions, and various odds and ends for debugging. This was a great way to build desktop applications, so long as you used it the way it was intended.
But if you wanted to do something the authors didn't anticipate, all these extra moving parts suddenly got in the way. As software became more and more about the web and the internet, this situation started happening all the time.
In the past, I used HTML editing suites like Macromedia Dreamweaver (as it was back then) and FirstPage for static websites. Again, I found the features could get in the way as much as they helped. These applications had their own ideas about how to organize your project, and if you had a different view, it was an awful bother.
More recently, after a long break from programming, I started learning the people's language: [Python][3]. I bought a book of introductory tutorials, which said to install [IDLE][4], so I did. I think I got about five minutes into it before ditching it to run the interpreter from the command line. It had way too many moving parts to deal with. Especially for HelloWorld.py.
But I always went back to Notepad++ and Nano whenever I could get away with it.
So what changed? Well, a few months ago I [ditched Windows 10][5] completely (hooray!). Sticking with what I knew, I used Nano as my main text editor for a few weeks.
I learned that Nano is great when you're already on the command line and you need to launch a Navy SEAL mission. You know what I mean. A lightning-fast raid. Get in, complete the objective, and get out.
It's less ideal for long campaigns—or even moderately short ones. Even just adding a new page to a static website turns out to involve many repetitive keystrokes. As much as anything else, I really missed being able to navigate and select text with the mouse.
### Introducing Geany
The Geany project began in 2005 and is still actively developed.
It has minimal dependencies: just the [GTK Toolkit][6] and the libraries that GTK depends on. If you have any kind of desktop environment installed, you almost certainly have GTK on your machine.
I'm using it on Xfce, but thanks to these minimal dependencies, Geany is portable across desktop environments.
Geany is fast and light. Installing Geany from the package manager took mere moments, and it uses only 3.1MB of space on my machine.
So far, I've used it for HTML, CSS, and Python and to edit configuration files. It also recognizes C, Java, JavaScript, Perl, and [more][7].
### No-compromise simplicity
Geany has a lot of great features that make life easier. Just listing them would miss the best bit, which is this: Geany makes sense right out of the box. As soon as it's installed, you can start editing files straightaway, and it just works.
For all the IDE functionality, none of it gets in the way. The default settings are set intelligently, and the menus are laid out nicely enough that it's no hassle to change them.
It doesn't try to organize your project for you, and it doesn't have strong opinions about how you should do anything.
### Handles whitespace beautifully
By default, every time you press Enter, Geany preserves the indentation on the new line. In addition to saving a few tedious keystrokes, it avoids the inconsistent use of tabs and spaces, which can sometimes sneak in when your mind's elsewhere and make your code hard to follow for anyone with a different text editor.
But what if you're editing a file that's already suffered this treatment? For example, I needed to edit an HTML file that was indented with a mix of tabs and spaces, making it a nightmare to figure out how the tags were nested.
With Geany, it took just seconds to hunt through the menus to change the tab length from four spaces to eight. Even better was the option to convert those tabs to spaces. Problem solved!
### Clever shortcuts and automation
How often do you write the correct code on the wrong line? I do it all the time.
Geany makes it easy to move lines of code up and down using Alt+PgUp and Alt+PgDn. This is a little nicer than just a regular cut and paste—instead of needing four or five key presses, you only need one.
When coding HTML, Geany automatically closes tags for you. As well as saving time, this avoids a lot of annoying bugs. When you forget to close a tag, you can spend ages scouring the document looking for something far more complex.
It gets even better in Python, where indentation is crucial. Whenever you end a line with a colon, Geany automatically indents it for you.
One nice little side effect is that when you forget to include the colon—something I do with embarrassing regularity—you realize it immediately when you don't get the automatic indentation you expected.
The default indentation is a single tab, while I prefer two spaces. Because Geany's menus are very well laid out, it took me only a few seconds to figure out how to change it.
You, of course, get syntax highlighting too. In addition, it tracks your [variable scope][8] and offers useful autocompletion.
### Large plugin library
Geany has a [big library of plugins][9], but so far I haven't needed to try any. Even so, I still feel like I benefit from them. How? Well, it means that my editor isn't crammed with functionality I don't use.
I reckon this attitude of adding extra functionality into a big library of plugins is a great ethos—no matter your specific needs, you get to have all the stuff you want and none of what you don't.
### Remote file editing
One thing that's really nice about terminal text editors is that it's no problem to use them in a remote shell.
Geany handles this beautifully, as well. You can open remote files anywhere you have SSH access as easily as you can open files on your own machine.
One frustration I had at first was I only seemed to be able to authenticate with a username and password, which was annoying, because certificates are so much nicer. It turned out that this was just me being a noob by keeping certificates in my home directory rather than in ~/.ssh.
When editing Python scripts remotely, autocompletion doesn't work when you use packages installed on the server and not on your local machine. This isn't really that big a deal for me, but it's there.
### In summary
Text editors are such a personal preference that the right one will be different for different people.
Geany is excellent if you already know what you want to write and want to just get on with it while enjoying plenty of useful shortcuts to speed up the menial parts.
Geany is a great way to have your cake and eat it too.
--------------------------------------------------------------------------------
via: https://opensource.com/article/19/3/getting-started-geany-text-editor
作者:[James Mawson][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/dxmjames
[b]: https://github.com/lujun9972
[1]: https://www.geany.org/
[2]: https://www.geany.org/Download/ThirdPartyPackages
[3]: https://opensource.com/resources/python
[4]: https://en.wikipedia.org/wiki/IDLE
[5]: https://blog.dxmtechsupport.com.au/linux-on-the-desktop-are-we-nearly-there-yet/
[6]: https://www.gtk.org/
[7]: https://www.geany.org/Main/AllFiletypes
[8]: https://cscircles.cemc.uwaterloo.ca/11b-how-functions-work/
[9]: https://plugins.geany.org/

View File

@ -0,0 +1,49 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Do advanced math with Mathematica on the Raspberry Pi)
[#]: via: (https://opensource.com/article/19/3/do-math-raspberry-pi)
[#]: author: (Anderson Silva https://opensource.com/users/ansilva)
Do advanced math with Mathematica on the Raspberry Pi
======
Wolfram bundles a version of Mathematica with Raspbian. Learn how to use it in the 12th article in our series on getting started with Raspberry Pi.
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/edu_math_formulas.png?itok=B59mYTG3)
In the mid-'90s, I started college as a math major, and, even though I graduated with a computer science degree, I had taken enough classes to graduate with a minor—and only two classes short of a double-major—in math. At the time, I was introduced to an application called [Mathematica][1] by [Wolfram][2], where we would take many of our algebraic and differential equations from the blackboard into the computer. I spent a few hours a month in the lab learning the Wolfram Language and solving integrals and such on Mathematica.
Mathematica was closed source and expensive for a college student, so it was a nice surprise to see almost 20 years later Wolfram bundling a version of Mathematica with Raspbian and the Raspberry Pi. If you decide to use another Debian-based distribution, you can [download it][3] on your Pi. Note that this version is free for non-commercial use only.
The Raspberry Pi Foundation's [introduction to Mathematica][4] covers some basic concepts such as variables and loops, solving some math problems, creating graphs, doing linear algebra, and even interacting with the GPIO pins through the application.
![](https://opensource.com/sites/default/files/uploads/raspberrypi_12_mathematica_batman-plot.png)
To dive deeper into Mathematica, check out the [Wolfram Language documentation][5]. If you just want to solve some basic calculus problems, [check out its functions][6]. And read this tutorial if you want to [plot some 2D and 3D graphs][7].
Or, if you want to stick with open source tools while doing math, check out the command-line tools **expr** , **factor** , and **bc**. (Remember to use the [**man** command][8] to read up on these utilities.) And if you want to graph something, [Gnuplot][9] is a great option.
--------------------------------------------------------------------------------
via: https://opensource.com/article/19/3/do-math-raspberry-pi
作者:[Anderson Silva][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/ansilva
[b]: https://github.com/lujun9972
[1]: https://en.wikipedia.org/wiki/Wolfram_Mathematica
[2]: https://wolfram.com/
[3]: https://www.wolfram.com/raspberry-pi/
[4]: https://projects.raspberrypi.org/en/projects/getting-started-with-mathematica/
[5]: https://www.wolfram.com/language/
[6]: https://reference.wolfram.com/language/guide/Calculus.html
[7]: https://reference.wolfram.com/language/howto/PlotAGraph.html
[8]: https://opensource.com/article/19/3/learn-linux-raspberry-pi
[9]: http://gnuplot.info/

View File

@ -0,0 +1,116 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How To SSH Into A Particular Directory On Linux)
[#]: via: (https://www.ostechnix.com/how-to-ssh-into-a-particular-directory-on-linux/)
[#]: author: (SK https://www.ostechnix.com/author/sk/)
如何在 Linux 上 SSH 登录到特定目录
======
![](https://www.ostechnix.com/wp-content/uploads/2019/02/SSH-Into-A-Particular-Directory-720x340.png)
你是否遇到过需要 SSH 登录到远程服务器并立即 cd 到一个目录来继续交互式作业?你找对地方了!这个简短的教程描述了如何直接 SSH 登录到远程 Linux 系统的特定目录。而且不仅是SSH 登录到特定目录,你还可以在连接到 SSH 服务器后立即运行任何命令。这些没有你想的那么难。请继续阅读。
### SSH 登录到远程系统的特定目录
在我知道这个方法之前我通常首先使用以下命令SSH 登录到远程系统:
```
$ ssh user@remote-system
```
然后如下 cd 进入某个目录:
```
$ cd <some-directory>
```
然而,你不需要使用两个单独的命令。你可以用一条命令组合并简化这个任务。
看看下面的例子。
```
$ ssh -t sk@192.168.225.22 'cd /home/sk/ostechnix ; bash'
```
上面的命令将通过 SSH 连接到远程系统 192.168.225.22 并立即进入名为 **“/home/sk/ostechnix/”** 的目录,并停留在提示符中。
这里,**-t** 标志用于强制分配伪终端,这是一个必要的交互式 shell。
以下是上面命令的输出:
![](https://www.ostechnix.com/wp-content/uploads/2019/02/ssh-1.gif)
你也可以使用此命令。
```
$ ssh -t sk@192.168.225.22 'cd /home/sk/ostechnix ; exec bash'
```
或者,
```
$ ssh -t sk@192.168.225.22 'cd /home/sk/ostechnix && exec bash -l'
```
这里,**-l** 标志将 bash 设置为登录 shell。
在上面的例子中,我在最后一个参数中使用了 **bash**。它是我的远程系统中的默认 shell。如果你不知道远程系统上的 shell 类型,请使用以下命令:
```
$ ssh -t sk@192.168.225.22 'cd /home/sk/ostechnix && exec $SHELL'
```
Like I already said, this is not just for cd into directory after connecting to an remote system. You can use this trick to run other commands as well. For example, the following command will land you inside /home/sk/ostechnix/ directory and then execute uname -a command.
就像我已经说过的,它不仅仅是连接到远程系统后 cd 进入目录。你也可以使用此技巧运行其他命令。例如,以下命令将进入 “/home/sk/ostechnix/”,然后执行命令 “uname -a” 。
```
$ ssh -t sk@192.168.225.22 'cd /home/sk/ostechnix && uname -a && exec $SHELL'
```
或者,你可以在远程系统上的 **.bash_profile** 文件中添加你想在 SSH 登录后执行的命令。
编辑 **.bash_profile** 文件:
```
$ nano ~/.bash_profile
```
每个命令一行。在我的例子中,我添加了下面这行:
```
cd /home/sk/ostechnix >& /dev/null
```
保存并关闭文件。最后,运行以下命令更新修改。
```
$ source ~/.bash_profile
```
请注意,你应该在远程系统的 **.bash_profile** 或 **.bashrc** 文件中添加此行,而不是在本地系统中。从现在开始,无论何时登录(无论是通过 SSH 还是直接登录cd 命令都将执行,你将自动进入 “/home/sk/ostechnix/” 目录。
就是这些了。希望这篇文章有用。还有更多好东西。敬请关注!
干杯!
--------------------------------------------------------------------------------
via: https://www.ostechnix.com/how-to-ssh-into-a-particular-directory-on-linux/
作者:[SK][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.ostechnix.com/author/sk/
[b]: https://github.com/lujun9972