File Commands
cat filename displays the contents of filename
cat filename(s) > newfile copies one or more files to a newly created newfile
cat filename >> destination appends the contents of filename to destination
chattr filename
changes the file attributes of filename (see lsattr)
changes the file attributes of filename (see lsattr)
chmod permission file_or_dir_name
changes
file permissions; (u) user's, (g) group's, (o) others'
rights
can be (+) added or (-) deleted in (r) read, (w) write or
(x)
execute mode. chmod u+x file adds execute
rights to user.
chown
file---- changes ownership of file to and
cp oldfilename newfilename ---copies oldfilename
to newfilename
file filename ----displays what type of file filename is
find /
-name “filename” searches
entire root directory for filename
grep string filename searches for and displays the string within filename
gunzip filename uncompresses filename (if
compressed with gzip)
gzip filename compresses filename (use gunzip to
uncompress)
head filename displays the first ten lines of filename
less filename displays the contents of filename with the ability to scroll
ln –s source target creates a soft link from source to target (i.e. a shortcut)
locate filename searches for and locates filename (commands AND files)
NOTE:
need to update db with root command “updatedb”
lsof lists
currently open files
more filename displays the contents of filename one screen at a time
mv oldfilename newfilename renames oldfilename
to newfilename
mv filename directoryname moves filename to directoryname
rm filename removes or deletes filename
rpm –Uvh package-name
installs package-name (upgrades if package already
present).
Add “--test”
to test for dependencies before install.
sort filename alphabetizes (sorts) filename
split –b1m file files. splits file into
multiple files.[x] files that are 1 MB each.
use cat
to re-assemble (ex: cat game.zip.* > game.zip)
stat filename provides statistics on filename (like windows file properties)
tail filename displays the last ten lines of filename. –f to show new output
tar -cvf newfile.tar fileordirectory
packs fileordirectory and call the package newfile.tar.
(tar -xvf
newfile.tar with will unpack the file)
touch file ----changes file timestamp of file (can also
create file)
tree -----shows the
directory tree of the current directory
vi a
(brutal) text editor. Use nano instead :)
wc –(l or w or c) file counts
total lines (l), words (w) and/or
characters (c) in file
whereis command -----locates the binary, source, manual of command (see locate)
which command ----prints
the location of command or the alias to which it
points
Comments
Post a Comment