Linux General Commands - yenbohuang/techNotes GitHub Wiki
lsb_release -a
Preferred
/etc/profile.d
System
/etc/profile
/etc/default/locale
/etc/bash.bashrc
/etc/sudoers
/etc/environment
See details on https://help.ubuntu.com/community/EnvironmentVariables
Files with the .sh
extension in the /etc/profile.d
directory get executed whenever a bash login shell is entered (e.g. when logging in from the console or over ssh), as well as by the DisplayManager when the desktop session loads.
You can for instance create the file /etc/profile.d/myenvvars.sh
and set variables like this:
export JAVA_HOME=/usr/lib/jvm/jdk1.7.0
export PATH=$PATH:$JAVA_HOME/bin
See details on https://help.ubuntu.com/community/EnvironmentVariables#A.2Fetc.2Fenvironment
To upgrade on a desktop system:
- Open the "Software & Updates" Setting in Systemsettings.
- Select the 3rd Tab called "Updates".
- Set the "Notify me of a new Ubuntu version" dropdown menu to "For any new version".
- Press Alt+F2 and type in "update-manager" (without the quotes) into the command box.
- Update Manager should open up and tell you: New distribution release '14.10' is available.
- Click Upgrade and follow the on-screen instructions.
To upgrade on a server system:
- Install the update-manager-core package if it is not already installed.
- Make sure the
/etc/update-manager/release-upgrades
is set to normal. - Launch the upgrade tool with the command sudo do-release-upgrade.
- Follow the on-screen instructions.
Note that the server upgrade will use GNU screen and automatically re-attach in case of dropped connection problems. There are no offline upgrade options for Ubuntu Desktop and Ubuntu Server. Please ensure you have network connectivity to one of the official mirrors or to a locally accessible mirror and follow the instructions above.
See details on https://wiki.ubuntu.com/UtopicUnicorn/ReleaseNotes
tar -vxjf /mnt/mydownloads/archive.tar.bz2
tar -vxzf /mnt/mydownloads/archive.tar.gz
unzip archive.zip -d /home/yenbo.huang/folder
See details on:
- http://logicassembly.com/linux/decompress_tar_dot_gz.htm?ext=bz2
- http://askubuntu.com/questions/86849/how-to-unzip-a-zip-file-from-the-terminal
sudo apt install chrony
https://help.ubuntu.com/lts/serverguide/NTP.html
sudo timedatectl set-timezone your_time_zone
https://linuxize.com/post/how-to-set-or-change-timezone-on-ubuntu-18-04/
uuidgen
md5sum <filename>
echo <string> | md5sum
locate <filename>
find <path> -name <filename>
which <filename>
whereis <filename>
See details on https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/4/html/Step_by_Step_Guide/s1-managing-locating.html
find <path> -type f -name '*.log' -delete
See details on http://unix.stackexchange.com/questions/116389/recursively-delete-all-files-with-a-given-extension
cp --parents `find -name \*.properties` /e/temp/props/
See details on https://stackoverflow.com/questions/15617016/copy-all-files-with-a-certain-extension-from-all-subdirectories
sudo <key1>=<value1> <key2>=<value2> .... <command>
See details on http://askubuntu.com/questions/57915/environment-variables-when-run-with-sudo
This is an example for docker daemon in /etc/systemd/system/docker.service.d/override.conf
:
[Service]
Environment="CONSUL_HTTP_TOKEN=<ACL token>"
ExecStart=
ExecStart=/usr/bin/docker daemon --insecure-registry <url:port> -H fd:// -s overlay
Run the following commands after changes:
#!/bin/sh
sudo systemctl daemon-reload
sudo systemctl enable docker
sudo systemctl start docker
See details on https://www.freedesktop.org/software/systemd/man/systemd.service.html
- To list top 10 directories eating disk space.
du -a ~/ | sort -n -r | head -n 10
- Display the amount of disk space used by the specified files and for each sub-directory.
du
See details on:
- http://www.cyberciti.biz/faq/linux-check-disk-space-command/
- https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-centos-7
some-command | tee -a file
See details on http://stackoverflow.com/questions/418896/how-to-redirect-output-to-a-file-and-stdout
some-command 2>&1
See details on http://superuser.com/questions/71428/what-does-21-do-in-command-line
ps -o user= -p <pid>
See details on https://unix.stackexchange.com/questions/284934/return-owner-of-process-given-pid/284938