Tech C**P
15 subscribers
161 photos
9 videos
59 files
304 links
مدرس و برنامه نویس پایتون و لینوکس @alirezastack
Download Telegram
tmux is a terminal multiplexer. It lets you switch easily between several programs in one terminal, detach them (they keep running in the background) and reattach them to a different terminal.
after installation you can list your sessions by:
tmux ls

Output would be something like this:
0: 1 windows (created Mon Aug  7 10:34:00 2017) [135x52] (attached)
2: 1 windows (created Mon Aug 7 13:56:10 2017) [126x25]

(attached) at the end of session 0 tells us that the session has been attached by a user.
You can attach a session by:
tmux attach -t 0
-t tells tmux which session should be attached.

Now let's say you want to detach a session you need to press ^b+d (CONTROL+b and then press d).

If you want to split your window to multiple panes press ^b+" (split horizontally) and/or ^b+% (split vertically).

^b+n : next window
^b+(up/down/left/right) : to move between panes
^b+? : help and shortcuts
^b+x : kill a pane

THE GREAT THING about tmux is that multiple users can attach the same session and work simultaneously!

I know you will get tired if I say more about tmux, so go and explore more yourself and see the real power of multiplexers.

#tmux #linux #sysadmin #terminal #multiplexer
In ls you can list files by using regex pattern as below:
ls data.subtitle_*

* is gready and list all the files that start with data.subtitle_.

Now lets say you want to get count of files which is listed by ls command. For that you can use wc -l as follow:
ls data.subtitle_* | wc -l

Now you shoud the count of files listed by the first command. This method of using 2 commands is piping commands, which is in fact separated by | (pipe)

#linux #sysadmin #ls #wc #command #bash #terminal
Use jq to process JSON in linux terminal. In order to parse JSON in linux you can use sed, awk and grep, but with jq it is far more easier.

https://stedolan.github.io/jq/

#jq #json #terminal #linux #sysadmin
If you have an script and you want to clear the terminal before executing your script you can use the below control characters:

print(chr(27) + "[2J")



The above command will clear the screen by using Python

#python #chr #terminal #clear_terminal
Do you think SSH sucks? Do you think SSH suck specially when you are from an unstable network like what we have in IRAN and when DPI (Deep Packet Inspection) is undergo? OK, I have mosh for you. mosh stands for Mobile Shell. It reconnects itself and you never have to login again. Even if you change your internet connection you are safe and your shell is open :)

Its security is like shell, as it uses shell authentication mechanism for login. You need to open UDP ports 60000 to 61000. Or you can give -p parameter to connect on a specific port:

mosh -p 60010 admin@my_server.com

One of the caveats of mosh is that you cannot scroll to previous commands as its buffer is limited to the window you are viewing itself.

Install it using apt-get install mosh.

For further instruction head over to link below:

https://mosh.org/

#ssh #mosh #terminal