Linux Commands
Linux Command has 3 parts(the command, command option and the arguments)
groupadd sales
eg useradd -m -aG sales linda
cmd option option Argument Argument to entire command
ls=list command
ll=long listing command
man ls= manual to a command
ls -la= will show all directory structure and those that have not contect in them
drwxr= directory,read,write,execute
uname= command to see the OS
uname -a= command to see OS and kernel details
uname –help=command to see details about a command
uname -r, uname -s, uname -p
ls -lh /etc/
hostname= command to see your hostname
hostname –help
man hostnamectl=give you details about the command.
hostnamectl=command to see details about your server
hostnamectl set-hostname =command to change or set hostname
date=command to see date and time on your system.
timedatectl=command to see time,date and you can use to set timezone,NTP,
who=command to see who is logged onto your system
man who= see details about the who command
whoami= command to see who is using the terminal
touch command=command used to create files in linux
you can create multiple users from one command line eg touch user1 user2 user3 user4
ls to see created files
pwd=print working directory
tree=to see linux file system
tab key on your computer will auto complete a command . also know in linux as bash completion.
If you hit tab and does nto complete, it means you are not typing the right command.
vim testing.sh
!/bin/bash
ls
sudo touch student1 student2 student3
hostnamectl
wq!
chmod 764 testing.sh
an executable file is green in color
rm = command to remove files and directories
man rm
rm testfile
mkdir=make directory
mkdir california
NB you cannot create a filename with a directory name that already exsist.
cd=command to change dirctory
tree home=command to see all files and directories in /home
cd .. =command to take a step backwards
cd ../.. =takes you two directories back
rmdir =command to delete a directory
NB rmdir can only remove an empty directory
echo “hello” > [filename]
rm -r =command to remove directory with content.
mkdir california/sanantonio
ls california
mkdir -p=create directories and subdirectories
cat=command to see content of a file
/etc/passwd =directory where users are stored in a system.
you cannot cat a directory,use ls
less =command to split the content of a file
cat /etc/passwd | less
history =command will give you a record of all the commands you have used on your system.
man history
| = pipe command
history | less =this will organize your history command output
use the space bar to navigate and q to quit
!398 = command to repeat an already executed command.
head tail less commands
tail -n 2
cat /etc/ssh/sshd_conf | tail -n 3 = will show last 3 lines
cp= command to copy
cp command has format=cp [source] [Destination]
copying a file to an absolute path
cp filename /home/server_admin/california
cp [source] [destination]
cp source ../../destination/
mv=command to move a file to another destination [a copy of this file after moved is not retained in this location.
mv= can also be used to rename a file
mv oldfilename newfilename
vim filename.html
hello world
<
a file with a – infront is a file