ProfMesser: Basic Linux Commands
what to type if you wanted to change directory to the var/log directory:
"cd /var/log"
command to get all of the information for the "eth0" adapter card:
"ifconfig eth0"
If you want to connect to an SSID
"iwconfig eth0 (name of adapter) essid(specify you want to connect to an essid) studio-wireless(name of the ssid)"
command to create a new directory called "notes":
"mkdir notes"
command to rename a file "first.txt" to "second.txt"
"mv first.txt second.txt"
command to view every process for every user:
"ps -e | more"
command to view user processes
"ps"
directories can be removed with rm this way:
"rm -r"
Command to change the owner of a file "script.sh" to "professor":
"sudo chown professor script.sh"
command to restart the computer after 3 minutes
"sudo shutdown -r 3"
syntax for starting the visual editor
"vi FILENAME"
command to start the visual editor for file "script.sh"
"vi script.sh"
chown (2):
- change file owner and group - sudo chown [OWNER:GROUP] file
chmod: change mode of a file system object (3):
- r=read, w=write, x=execute, - can also use octal notation, - set for the file owner (u), the group (g), others(o), or all(a)
iwconfig (4):
- view or change wireless network configuration - essid, frequency / channel, mode, rate, etc. - requires some knowledge of the wireless network - iwconfig eth0 essid studio-wireless
apt-get (4):
-Advanced Packaging Tool - Handles the management of application packages - Install, update, remove - sudo apt-get install wireshark
su (3):
-Become super user - Or change to a different user, - You continue to be that user until you type "exit"
passwd (2):
-Change a user account password - Yours or another - passwd [username]
cd (3):
-Change current directory - nearly identical to Windows command but uses forward slashes instead - cd <directory>
sudo (3):
-Execute a command as the super user, - Or as a different user ID, - Only that command executes as the super user
grep (2):
-Find text in a file, - grep PATTERN [FILE]
ls:
-List directory contents (similar to dir in Windows), - Lists files, directories, - For long output, pipe through more: "ls -l | more"
pwd (3):
-Print Working Directory, - Displays the current working directory path, - Useful when changing directories often
ps:
-View the current processes - and the process ID (PID) - similar to the Windows Task Manager - View user processes (ps) - view all processes for all users (ps -e | more)
cp (2):
-duplicate files or directories, - cp SOURCE DEST
apt-get: Advanced Packaging Tool:
-easily find packages and install them into your Linux distribution - handles the management of application packages
mkdir (2):
-make a directory, - mkdir DIRECTORY
rm (2):
-remove files or directories, - does not remove directories by default. Directories must be removed with "rm -r"
mv (2):
-rename a file, - move a file
"apt" in apt-get stands for
Advanced Packaging Tool
Commands looked at in this video are similar in both
Linux and Mac OS
Command to shutdown or start a Linux device
SHUTDOWN
permissions of file separated into:
User, Group, Other. rwx(user)rwx(group)rwx(other)
popular editor that's found in almost every Linux distribution
Vi
The grep command is
a search function that allows you to look for some text that may be located in one or more files.
command: chmod a-w first.txt would mean that
all users would not be able to write to first.txt
One common command to install, update, or remove applications from the command line is
apt-get
command that allows you to change the directory
cd
cd command allows you to
change directory
command to change the file permissions
chmod
command to set permissions of file: script.sh to user: read, group: write, other: execute:
chmod 421 script.sh
command to set permissions of file: script.sh to user: read write execute, group: read write execute: other: read write execute.
chmod 777 script.sh
chmod syntax:
chmod mode FILE
command to copy a file
cp
cp syntax:
cp SOURCE_NAME _DESTINATION_NAME
command to copy the file "first.txt" and rename the copied file "second.txt":
cp first.txt second.txt
ls: If you were in Windows you would be using the __ command.
dir
some commands require
elevated rights
rmdir can remove
empty directories
chmod: permissions denoted by 1
execute only
what the ps command does
lists out all of the current processes and process IDs
How to get long output with ls command
ls -l
what the command "sudo chown professor script.sh" does
makes the owner of script.sh "professor"
man command stands for
manual
command to create directory
mkdir
mkdir syntax
mkdir DIRECTORY
what mv command does
move a file, rename a file.
command to move a file
mv
command to rename a file
mv
In Linux, every file is
owned by a particular user, and there are also rights and permissions associated with a group that may be associated with that file.
command to change the password for your account
passwd
ls: for long output ...
pipe through more: "ls -l | more". Use "q" or Ctrl - c to exit
Command to cancel a shutdown or restart
press "Ctrl -c"
Once you're inside vi, you can insert text by:
pressing the "i" key, and then specifying what text you'd like to have input.when you're finished with the input process, you will usually press Escape to get out of input mode.
command to find out what directory currently in
pwd
chmod: permissions denoted by 5
read and execute
chmod: permissions denoted by 6
read and write
chmod: permissions denoted by 4
read only
chmod: permissions denoted by 7:
read, write, and execute
chmod: usually changing the mode to be either:
read, write, or execute
rm stands for
remove files or directoires
command to remove file with filename: "temp-1.doc":
rm temp-1.doc
Directories must be empty to be removed with
rmdir
shutdown: you usually are going to...
run this as a superuser
apt-get command to install Wireshark
sudo apt-get install wireshark
chown syntax:
sudo chown [OWNER:GROUP] file
Command to wait 2 minutes then shutdown the computer
sudo shutdown 2
cd similar to cd in Windows. Difference is...
that in Linux we are going to use forward slashes instead of backslashes
You usually access the Linux command line by using
the Terminal, XTerm, or some similar terminal program.
ps is similar to
the Windows Task Manager
The cd command in linux is very similar to
the cd command in Windows that allows you to change directory.
Whenever you're working at the command line with these files and you need to change these rights and permissions...
the chmod will be the utility that you use to do that.
chmod: change mode of a file system object (3): set for...
the file owner (u), the group (g), others(o), or all(a)
To make a directory in Linux, we use
the mkdir command
command: chmod u+x first.txt would mean that
the owner of script.sh can execute the file
similar to the Windows Task Manager
the ps command
If you don't know what directory you're currently in...
use the "pwd" command. Stands for print working directory
chmod: permissions denoted by 744:
user: read, write, and execute, group: read only, other: read only
ifconfig:
view or configure a network interface and IP configuration
what command "sudo shutdown 2" does
waits 2 minutes then shuts down the computer
chown: if we want to change the ownership of a file...
we may want to look at who owns the file currently, If we use the ls -l command, we can see that script.sh <example> is owned by backup and is part of the group "staff."
To be able to change the file owner or the group owner...
we would use the chown command, and usually you have to use elevated rights
To use grep...
we would use the grep command, we would specify a pattern, and then specify what files we wanted to look inside: - "grep PATTERN [FILE]" -example: "grep failed auth.log"
To delete a file from a filesystem...
we would use the rm command
chmod: permissions denoted by 3
write and execute
chmod: permissions denoted by 2
write only
if you have a number of tasks that you need to execute as the superuser,
you can start this mode by simply typing in "su"
If you want to see the IP address configurations of any of your network adapters,
you can use ifconfig
If you'd like to execute just one command in the superuser mode,
you can use the "sudo" command.
If you want to view or change any of the wireless configuration settings of a wireless adapter inside Linux...
you want to use the iwconfig command