Common Linux terminal commands
Favorite Linux commands
ls-List files and ddirectories. Use the-laflag for more detailscd [directory]- Change directory. This command can also be used double dots to go back one levelcd ..or with dashcd -to go back to previous directory.cd ~orcdto get to HOME directory andcd /to get to root directory.mkdir [directory]-Make directoryrm [file | directory]removes a file of directory. If the directory is not empty. use the recursive flag-rCTRL+l-Clear screenCTRL+r-Find a previous command. HitCTRL+rand start typing to find a command you have used beforewhoami-Show the current usersudo [command]-Run command as rootsudo su-Change user torootfind -name [name of file]-Find a file by namegrep -R ./ -e "[seach pattern]"-find files containing a word or patterncat [file name]-View content of filedf -h-shows available and used disk space on the Linux systemlsblk-List information about block devices and partitionschmod +x [file name]-Makes file executablegrep- is used to filter output such asdf -h | grep udevreturns only one row from thedfcommandasw- spits an input into an array. For instancedf -h | grep udev | awk '{print $2}'returns only the second column.
grep and awk sample
$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 315M 0 315M 0% /dev
tmpfs 91M 1.2M 90M 2% /run
/dev/mmcblk0p2 29G 4.8G 22G 18% /
tmpfs 454M 8.0K 454M 1% /dev/shm
tmpfs 5.0M 12K 5.0M 1% /run/lock
/dev/mmcblk0p1 510M 75M 436M 15% /boot/firmware
tmpfs 91M 44K 91M 1% /run/user/1000
$ df | grep udev
udev 322452 0 322452 0% /dev
$ df | grep udev | awk '{print $2}'
322452
Favorite vi commands
vi or vim is a commonly used file editor, which can be complex to use, but here are a few commands to get you started.
- To open a file with
vi, typevi [file name] - To edit the content, hit
i - To delete a row, hit
d+d - To leave a mode (such as edit), hit
ESC+ESC - To save your changes, hit
w - To quit
vi, hitworwqto save and quit
Favorite less commands
less is a great tool for analyzing log files.
- Open a log file, use
sudo less /var/log/syslog. Use the-Sflag to wrap long lines` - Use
bto go backward one window - Use
fto go forward one window - Use
Gto go to the end of file - Use
gto go to the beginning of file - Use
/to search forward - Use
?to search backward
Favorite systemctl commands
systemd is a software suite that provides an array of system components for Linux operating systems, such as daemons (services). systemctl is the tool you use to interact with systemd
systemctl start [daemon]starts a daemonsystemctl stop [daemon]stops a daemonsystemctl restart [daemon]re-starts a daemonsystemctl cat [daemon]view the service filesystemctl daemon-reloadapplies changes made to any service file.
Favorite journalctl commands
-
journalctlis also part of thesystemdsuite and helps you view logfile in real-time. -
journalctl -u [service] -n [number of previous lines] -f.
E.g.
journalctl -u microservicebus-node -n 100 -f
journalctl --since [date]show logs from specified datejournalctl --until [date]show logs until specified date
E.g.
journalctl --since "2020-11-23" --until "2022-11-09 13:00"
journalctl --since yesterday --until "15 min ago"
Related content:
- Home
- Common Linux terminal commands
- Get insight using tracking
- Import nodes from CSV files
- Installing microServiceBus-node
- Working with meter configuration
- Migration information
- Node installation scripts
- Work with Node VPN interface and peers
- Reviewing the Audit log
- Roles, privilages and auditing
- Running microServiceBus-node on a yocto image
- Developing JavaScript Services in microServiceBus.com
- Developing Python Services in microServiceBus.com
- Site verification
- Using the Node terminal
- Using the Console
- Default keyboard shortcuts
- Working with service properties
Report bugs, broken links or missing images.. Create Issue
microServiceBus.com DOCS