Linux

  • Linux,  工具,  技术

    Mac command line cheat sheet

    Behavior Command Comment go to the beginning of the line ctrl+a go to the end of the line ctrl+e Save a output of a command to a env variable principle_arn=$(aws –profile perAdmin sts get-caller-identity –query Arn –output text) use a env variable ${principle_arn} replace character sed -e “s|PRINCIPAL_ARN|${principle_arn}|g” \assume-role-policy-template.json > assume-role-policy.json The delimiter of choice is a forward slash (/), which is the most commonly used delimiter. However, sed can use any character as a delimiter. In fact, it will automatically use the character following the s as a delimiter-e means you can use the followed scripts multiple times.https://unix.stackexchange.com/questions/33157/what-is-the-purpose-of-e-in-sed-command

  • Linux,  技术

    How to change default port for Apache2

    This example is for Ubuntu. Run sudo apachectl -S to check which conf file you are using. The result is something like: Then update the file /etc/apache2/sites-enabled/000-default.conf. Change the default file in that file. You need to change another file /etc/apache2/ports.conf. to update it to the right port. Restart apache sudo service apache2 restart Then check the status: sudo apachectl -S Done.

  • Linux,  技术

    How to handle storage running out of space issue in linux

    If you run out of space in one disk and you want to add a new one but you would like to move the existing data to the new disk, what would you do? Step 1: Identify the big folder Identify the folder which has the biggest files and you want to move. Here is the command you may want to run: -S Do not include the size of subdirectories. This is very useful and it would exclude the parent folder if the child folder on the list already. This would save you a lot of trouble to de-dup. the two -h should use together. We list the human readable…

  • Linux

    如何在Linux访问Mac文件系统

    如果你在家里自己搭建了一个Linux服务器,有时候需要把本地Mac笔记本里面的文件映射到远程linux服务器。比如说你需要: 在远程Linux运行docker,docker有时候需要把本地的文件目录mount到container里面。但是这个时候docker engine的本地其实是linux服务器。这个时候就需要两次link。把mac的文件目录mount到远程linux,然后再通过docker把linux的host目录mount到container。 单纯的文件拷贝。这个比scp要方便。 做法其实很简单,就是修改’etc/fstab’,加上下面这行: 192.168.103.168:/System/Volumes/Data/Users/abc /mnt/abcMap nfs defaults 0 0 这种做法默认是没有写的权限,如果需要写的权限,不能直接用chmod在linux下改,而是需要在mac电脑上用chmod把其他用户组也授予写的权限。 注意当添加子目录的时候,mac默认是其他用户组还是没有权限,这时候每添加一个新的目录,就需要再修改一次权限。