Saturday, January 5, 2019

MacOS basic commands

1. Copy a folder into another folder


cp -r /path/folder/a /path/folder/b

result:
/path/folder/b
/path/folder/b/a

2. Move a folder into another folder


mv /path/folder/a /path/folder/b

result:
/path/folder/b
/path/folder/b/a

3. Remove files


rm -rf /path/to/file
rm -rf /path/to/file*

4. Process and ports


lsof -iTCP -sTCP:LISTEN -n -P
lsof -iTCP -sTCP:LISTEN -n -P | grep {PORT}

5. Kill a process


kill -9 ${PID}

6. Change owner of a folder


# for current user
sudo chown -R `id -un` /path/to/folder
# a user
sudo chown -R ${username} /path/to/folder

No comments:

Post a Comment