man command
checks out the manual for the command
, for instance use man echo
to see the description of the echo
command.
Use q
to quit the manual mode, normally q
works for the similar mode entered by other command like ri Array
.
Use ctrl + C
to kill current exucution of code, break the unfinit loop, etc.
Use echo "some string" > file.txt
to through "some string" to "file.txt". use echo "another thing" >> file.txt
to concat the "another string" into the "file.txt". By default echo
appends \n
to the end of the string.
Output the file content on the command line use cat
command.
cat file_1.txt file_2.txt > combined_file.txt
can pass the file_1.txt and file_2.txt content to the combined_file.txt.
head file_name.txt
list the first 10 lines of a file
tail file_name.txt
list the last 10 lines of a file
wc file_name.txt
list the "line counts", "word counts", and "bytes" of the file
less file_name.txt
has /search_word
function to inspect the file less wiki page
ls -l
list out files in long format
ls -la
list out all files in long format, including the hidden files
ls -rtl
list out files in long format, with reversed order by recent modify time.
ls -lh
list out files in long format, with human readable file size count (K instead of bytes).
mv file_a.txt file_b.txt
rename file_a.txt to file_b.txt
rm file_a.txt
remove file_a.txt rm -rf file_a.txt
force remove file_a.txt
cp file_a.txt file_b.txt
copy file_a.txt to file_b.txt
diff file_a.txt file_b.txt
to show the difference between two file. There won't be output if the two files has no difference.
which ruby
checks whether ruby is installed in the computer
grep -i string file.txt
means catch all case insensitive "string" in "file.txt"
grep string file.txt | wc
pipes the result of grep and pass it to wordcount programme
grep -ri string directory
can find string
from the very deep level, starts from the directory
, case insentitive
ps aux | grep string
in processes status shows in aux
options and pipe result to grep
then grep the "string" form ps aux
result
kill -15 <pid>
to kill the individual process with process id
pkill -15 -f spring
can kill all process contains string spring
home directory is normally /Users/username/
alias ~/
use sudo
command to get root
permission for operation
mkdir
to make new directory
pwd
to print current working directory
find . -name '*.txt'
to find files whose names match the pattern *.txt, starting in the current directory . and then in its subdirectories
open file.ext
will open the file.ext with default programe to the .ext files
open .
will then execute finder
and open current directory
command line1 ; command line2 ; command line 3
use ;
to combine three commands in single line, and execute the three commands one after another
command line1 && command line2 && command line3
works similar as ;
seperator, using &&
can make the following command execute only if previous command successfully executed.
edit .zshrc
file with the resired configs and save it
source .zshrc
to reload the config
.bashrc
is the config file for bash shell