short arguments usually have a single dash followed by a single character. An example is ls -a
, where -a
is an additional flag/attribute that indicates to the ls
command that you should list all files, even if hidden by a .
long arguments usually have two dashes followed by a word or phrase (connected by dashes). An example is ls --all
, where --all
has the same meaning as -a
above.
<command> -h
: display help<command> --help
: display help (long form of argument)man <command>
cd <absolute or relative path>
: change directory to the path indicatedls
: list files in current directoryls -la
: list all files(a
) in list format(-l
)chown <username>:<groupname> <file or folder>
: change the owner of the file or folderchown -R <username>:<groupname> <file or folder>
: change the owner of the folder recursivelychmod <0-7><0-7><0-7> <file or folder>
: change the owner:group:anyone permissions for a filechmod -R <0-7><0-7><0-7> <file or folder>
: change the owner:group:anyone permissions for a folder recursivelychmod +x <file or folder>
: add execution permission to a file/foldersudo+<command>
mkdir <path>
: make a directory at path indicatedmv <path1> <path2>
: move a file from first path indicated to second path indicatedcp <path1> <path2>
: copy files from first path indicated to second path indicatedcp -r <path1> <path2>
: copy files recursively from first path indicated to second path indicatedrmdir <path>
: delete a folder at a given path (folder must be empty)rm <path1> ...
: delete a file at a given path(s)rm -rf <path> ...
: delete a file/folder at a given path(s) using the force
and recursive
option (removes folders too, be careful!) |key combineation | meaning |
---|---|
ctrl+c | stops execution of whatever is running in bash |
ctrl +alt +t | opens up a new bash terminal window |
ctrl +shift +t | opens up a new bash tab |
ctrl +shift +w | closes the current bash tab |
ctrl +shift +q | closes all bash tabs |
$HOME
$USERNAME
$PWD
$USER
$PATH
$PYTHONPATH
printenv
list all current environment variables
export
will save an environment variable across sessions
chown
chmod
sudo
ps
kill
killall
htop
grep
pwd
printenv
export
cat
login
shutdown
reboot
diff
rclone
cd
mv
rsync
scp
ssh
echo
mkdir
rm
rmdir
cp
touch
ln
chgrp
to run something as root
sudo <command> [command options]
to run interactively as root
sudo -i
to run something as someone else
sudo -i -u <username>
run exit
to leave that session
To change the file in place:
sed -i "s/regex/replace/" file
or
sed -i "s|regex|replace|" file
To copy output to a new file
sed "s/regex/replace/" filein > fileout
#chown -R <owner> <folder_1> <folder_2> ... <folder_n>
chown -R user /home/user
ls -l1 | wc -l
stat /path/to/filename
stat -c '%A %a %n' /path/to/filename
printenv | grep ROS
see the last few lines
#tail -100 <filename>
tail -100 history.txt
see real-time changes to files as they get appended:
tail -f history.txt
see line 196-200 of a file
head -200 history.txt | tail -5
tree /path/to/dir
awk '{print $1}' <filename>
cat <filename> | awk '{print $1}'
awk -F , '{print $1}' <filename.csv>
unset HISTFILE && exit
or
history -c && history -w && exit