Linux Command Examples Updated
Linux Command Examples Updated
export EDITOR=nano
(Set default text editor to nano)
export HISTSIZE=1000
(Set command history size)
echo $HOME
(Print the home directory path)
Running Commands in Background
or Virtual Consoles
long_running_command &
(Run a command in the background)
sleep 60 &
(Sleep for 60 seconds in the background)
fg %1
(Bring the first background job to the foreground)
Ctrl+Alt+F1 to F6
(Switch between virtual consoles)
Use of Aliases
alias ll='ls -l'
(Create alias ll for ls -l)
unalias ll
(Remove the alias ll)
df -h | grep '/dev/sda1'
(Filter disk space output for a specific partition)
find . -type f | wc -l
(Count the number of files in current directory)
Clobbering
echo 'New content' > file.txt
(Overwrite file.txt with new content)
ls > file_list.txt
(Overwrite file_list.txt with the output of ls)
export LANG=en_US.UTF-8
(Set language and locale settings)
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk
(Set the JAVA_HOME variable)
jobs
(List all background jobs)
bg %1
(Resume a suspended job in the background)
Use of Aliases
alias gs='git status'
(Create alias gs for git status command)
alias cls='clear'
(Create alias cls for clear command)