- How to check for Linux distribution name and version?
- How to check kernel version?
- What is the purpose of "&" at the end of a command?
With "&", the process starts in the background and you can continue using the same terminal.
- How to check system date/time?
- How to adjust system date/time?
date --set="1 July 2017 15:22:00"
- How to shutdown a Linux machine from terminal?
In Ubuntu, what is the different between "apt-get update" and "apt-get upgrade"?
apt-get update updates the list of available packages and their versions, but it does not install or upgrade any packages. apt-get upgrade actually installs newer versions of the packages you have.
How to add a path into environment variable?
What is the purpose of "pwd" command?
To view current working directory.
If you wish to know more details about a command, which command you should use?
How to execute multiple commands in one line?
Use && symbol:
cd /my_folder && rm *.tar.gz
How to add a user into Super User group?
gpasswd wheel -a <user>
How do you change password?
How to work in root environment?
How to view driver message?
How to clear driver message?
What is Yocto and how does it differ from other Linux distributions?
While Ubuntu, Red Hat, CentOS are some of Linux distributions (distro), Yocto allows you to create your own Linux recipes and build your own distro. In most cases, Yocto image only contains components required, making file size much smaller which is essential for mobile platform such as IVI (In-Vehicle Infotainment) system. More information can be found in Yocto official website.
- How to display files under current directory?
- How to show hidden files?
- How to calculate size of a directory?
du -h SomeDir
- How to check disk usage?
- How to list down last 15 lines of a text file (e.g. error.log)?
tail -n 15 error.log
- How to list down last 15 lines of a text file and keep the screen updated?
tail -n 15 -f error.log
- How to find all files with certain file name?
find / -name "filename"
- How to filter output by certain keyword?
cat output.txt|grep SomeText
- How to change ownership of a file to another person?
chown user2 SomeFile
- How to make a file executable?
chmod +x <filename>
- In "chmod 777", what does 777 mean?
The first digit refers to permission for the owner of the file/directory. The second is group permission. Third is world permission. 777 means to give full permission to the world.
- What is umask and what does "umask 022" mean?
When you create a file or directory in Linux, the particular file/directory will be given a default permission. "umask" allows you to change default permission. "umask 022", for example, will give the owner read, write and execute permissions whereas everyone else has read and execute permissions.
- How to create an empty file?
- How to edit a text file?
Use vi or vim:
- How to softlink a file?
ln -sf <existing_file> <link_to_create> For example: ln -sf iu3d_dri.so i965_dri.so
- Supposing you created a new directory call /mnt/WinDir. How do you mount a network Windows drive to this directory?
mount -t cifs -o user=<username>,pass=<password> //<ip_addr>/<some_dir> /mnt/WinDir
- How to compress a directory into a Tarball?
tar zcf NewFileName.tar.gz DirToCompress/
- How to save terminal output to a file?
Use ">" sign, for exaple:
startx > output.log
- How to copy a file to another location?
cp /SomeDir/SomeFile /NewDir/NewFile
- How to move a file to another location?
mv /SomeDir/SomeFile /NewDir/SomeFile
- How to move a non-empty directory?
rsync -a <source_directory> <target_directory>/ rm -rf <source_directory>
- How to remove a non-empty directory?
rm -rf <directory>
- How to list down all services available in a Linux machine?
- What does the "+" and "-" signs mean in "service --status-all" command?
"+" means the service is running whereas "-" is not.
- How to show processes using most memory?
Run "top", then type "M" to sort by memory usage.
- Following the questio above, how to show only top 10 processes using most memory?
While "top" is running, type "n", enter "10".
- How to check available memory?
- How to kill a process?
killall <process_name> - or - pkill <process_name>
- What is the purpose of "-9" in "kill -9 PID"?
To kill a process forcefully.
- What is systemctl?
To start/stop/restart/check status of a service.
- How to start a service?
systemctl start <service>
- How you schedule a command to run at specific interval?
Use cronjob. For example, if you with to run a script (e.g. example.sh) at 3am daily, run "crontab -e". Then, add the following line:
00 3 * * * /bin/sh /scripts/example.sh
- In cronjob, there are 5 asterisks. What does each asterisk means?
From left to right:
- Without using cronjob, how to issue a command at specific interview (e.g. every 5 seconds)?
Use "watch". The following command will execute "free -m" command every 5 seconds:
watch -n 5 free -m
- What is the command to list down all IP addresses?
- How to ping an IP address for 5 times?
ping 127.0.0.1 -c 5
- What is the terminal command to download a file from Internet?
- How do you access Linux terminal from a remote machine?
ssh [email protected]_host
- How to transfer a file from e.g. Windows machine to Linux machine?
Best way is to use WinSCP. Alternatively, use command:
scp file.txt [email protected]:/opt/
- What are the default port for HTTP/FTP/SSH?
- How to change SSH port?
a) vi /etc/ssh/sshd_config
b) Change "Port" value to desired value
c) Save the file.
d) Restart daemon: systemctl restart sshd.service
- How to FTP into a FTP server?
ftp -i <domain_name>
How to download multiple files from a FTP server?
The following command will download all Tarballs to current local directory:
How to upload multiple files to a FTP server?
- How to launch X11?
How to kill X11?
Why I can't run a X11 program from remote terminal?
You need to export DISPLAY:
How do you check for OpenGL version in X11?
How do you change screen resolution in X11?
Use "xrandr" to check all available mode first, then:
xrandr --output HDMI1 --mode 1024x768
How to turn off X11 screen?
xset dpms force off
How do you launch Wayland?
weston --tty=1 --idle-time=0
How do you kill Wayland?
I would like to say "Thank You" to the author of this article.
Kindly like our Facebook page at https://www.facebook.com/littlecpu/