unix

工具系列 | Docker基本概念小结

自闭症网瘾萝莉.ら 提交于 2020-01-22 09:24:32
▍什么是Docker? Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的镜像中,然后发布到任何流行的 Linux或Windows 机器上,也可以实现虚拟化。容器是完全使用沙箱机制,相互之间不会有任何接口。 ▍什么服务模式?C/S模式。Docker是一个客户端-服务端(c/s)的架构程序。docker是以客户端(client)和守护进程(server)来运行。 ▍什么通信方式? Unix的socket套接字,如:unix:///var/run/docker/sock(默认连接方式) ▍那几部分组成? Docker Client客户端 Docker Daemon服务端(守护进程) Docker Image 镜像 Docker Container 容器 ▍什么是Docker 仓库(hub)? 仓库(Repository)是集中存放镜像的地方。目前 Docker 官方维护了一个公共仓库 dDocker Hub。大部分需求都可以通过在 Docker Hub 中直接下载镜像来实现。 ▍什么镜像(image)? 可理解为一个面向Docker引擎的只读模板,包含了文件系统。如:一个镜像可以只包含一个完整的操作系统环境,也可以安装了其他的应用程序。通过版本管理和增量的文件系统,Docker提供了一套十分简单的机制来创建和更新现有的镜像。 ▍如何构建镜像?

Error: “grep: Argument list too long” [duplicate]

随声附和 提交于 2020-01-22 07:36:24
问题 This question already has answers here : How can I grep while avoiding 'Too many arguments' [duplicate] (5 answers) Closed 4 years ago . I am trying to run the following command, but gets argument too long error. Can you help?. HOST# grep -rl 'pattern' /home/*/public_html/* -bash: /bin/grep: Argument list too long Is there a way to override this error and grep the pattern matching files I want in all users public_html directory. There are around 500+ users in the same server. 回答1: Use find

How to update to C++11?

…衆ロ難τιáo~ 提交于 2020-01-22 07:08:13
问题 I am new to programming, so have never experienced a language update. With the release of C++11, I want to make use of all the new features such as lambda expressions and threads. I know I can do this with external libraries but using native language features would be more convenient. I am using gcc 4.2.1 on Mac OS X Snowleopard in Xcode 3.2.6 What all do I need to do and update to start using C++11 features? 回答1: You can update to Xcode 4.1 (or whatever the most recent version you can get

Declaring char array causes execv() to not work

╄→尐↘猪︶ㄣ 提交于 2020-01-22 02:41:20
问题 I wrote the following code in order to use pipes in c unix: #include <stdio.h> #include <sys/types.h> #include <sys/wait.h> #include <unistd.h> #include <string.h> int main () { int fds[2]; pid_t pid; /* Create a pipe. File descriptors for the two ends of the pipe are placed in fds. */ pipe (fds); /* Fork a child process. */ pid = fork (); if (pid == (pid_t) 0) { //char abc[10]; - **Uncommenting this cause the program not to work.** /* This is the child process. Close our copy of the write

How to read Windows file in Linux environment?

蹲街弑〆低调 提交于 2020-01-21 14:38:49
问题 I'm trying to execute a Python program on Linux which I first created on Windows, but the following error is shown: metadata = eval(metafile.read()) File "< string >", line 1 @ @ @ @ @ @ Any idea? 回答1: dos2unix yourfile.py python yourfile.py If you don't have dos2unix , here is some python code you can use instead. Just put this in dos2unix.py, and run python dos2unix.py yourfile.py above: import sys filename = sys.argv[1] text = open(filename, 'rb').read().replace('\r\n', '\n') open(filename

perl - replace every nth (and multiples) occurrences of a character with another character

♀尐吖头ヾ 提交于 2020-01-21 12:23:35
问题 Does anyone know any unix commands/perl script that would insert a specific character (that can be entered as either hex (ie 7C) or as the actual character (ie |)) in the position of the nth recurring occurence of a specific character. ie perl script.pl "," 3 "|" data.txt would replace every 3rd,6th,9th...etc comma with a pipe. So if data.txt had the following before the script was run: fd,3232,gfd67gf, peas,989767,jkdfnfgjhf, dhdhjsk,267,ujfdsy,fuyds,637296,ldosi,fduy, 873,fuisouyd,try save

perl - replace every nth (and multiples) occurrences of a character with another character

佐手、 提交于 2020-01-21 12:23:11
问题 Does anyone know any unix commands/perl script that would insert a specific character (that can be entered as either hex (ie 7C) or as the actual character (ie |)) in the position of the nth recurring occurence of a specific character. ie perl script.pl "," 3 "|" data.txt would replace every 3rd,6th,9th...etc comma with a pipe. So if data.txt had the following before the script was run: fd,3232,gfd67gf, peas,989767,jkdfnfgjhf, dhdhjsk,267,ujfdsy,fuyds,637296,ldosi,fduy, 873,fuisouyd,try save

ssh command -T option

社会主义新天地 提交于 2020-01-21 07:54:07
问题 I'm wondering what the -T option in the following command does, cannot see this option in the manual somehow: $ ssh -T git@gitlab.com Welcome to GitLab, Simeon ! Could somebody explain? 回答1: I explained before what TTY was: a text terminal is needed when you open an interactive session to a remote server. But: in the context of a remote Git repository hosting server (GitHub, Gitlab, BitBucket, ...), no remote server will ever allow you to open an interactive session (for security reason) Then

SIGKILL init process (PID 1)

两盒软妹~` 提交于 2020-01-21 04:51:09
问题 I'm facing a weird issue regarding sending signal 9 (SIGKILL) to the init process (PID 1). As you may know, SIGKILL can't be ignored via signal handlers. As I tried sending SIGKILL to init, I noticed that nothing was happening; init would not get terminated. Trying to figure out this behaviour, I decided to attach myself to the init process with strace too see more clearly what was happening. Now comes the weird part. If I'm "looking" at the init process with strace and send it SIGKILL, the

Why ssh fails from crontab but succedes when executed from a command line?

ぐ巨炮叔叔 提交于 2020-01-21 02:33:07
问题 I have a bash script that does ssh to a remote machine and executes a command there, like: ssh -nxv user@remotehost echo "hello world" When I execute the command from a command line it works fine, but it fails when is being executed as a part of crontab (errorcode=255 - cannot establish SSH connection). Details: ... Waiting for server public key. Received server public key and host key. Host 'remotehost' is known and matches the XXX host key. ... Remote: Your host key cannot be verified: